diff options
30 files changed, 1357 insertions, 190 deletions
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index c787ae512120..0ef00bd6e54d 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt | |||
| @@ -776,6 +776,13 @@ This will delete the directory debian, including all subdirectories. | |||
| 776 | Kbuild will assume the directories to be in the same relative path as the | 776 | Kbuild will assume the directories to be in the same relative path as the |
| 777 | Makefile if no absolute path is specified (path does not start with '/'). | 777 | Makefile if no absolute path is specified (path does not start with '/'). |
| 778 | 778 | ||
| 779 | To exclude certain files from make clean, use the $(no-clean-files) variable. | ||
| 780 | This is only a special case used in the top level Kbuild file: | ||
| 781 | |||
| 782 | Example: | ||
| 783 | #Kbuild | ||
| 784 | no-clean-files := $(bounds-file) $(offsets-file) | ||
| 785 | |||
| 779 | Usually kbuild descends down in subdirectories due to "obj-* := dir/", | 786 | Usually kbuild descends down in subdirectories due to "obj-* := dir/", |
| 780 | but in the architecture makefiles where the kbuild infrastructure | 787 | but in the architecture makefiles where the kbuild infrastructure |
| 781 | is not sufficient this sometimes needs to be explicit. | 788 | is not sufficient this sometimes needs to be explicit. |
| @@ -95,5 +95,5 @@ PHONY += missing-syscalls | |||
| 95 | missing-syscalls: scripts/checksyscalls.sh FORCE | 95 | missing-syscalls: scripts/checksyscalls.sh FORCE |
| 96 | $(call cmd,syscalls) | 96 | $(call cmd,syscalls) |
| 97 | 97 | ||
| 98 | # Delete all targets during make clean | 98 | # Keep these two files during make clean |
| 99 | clean-files := $(addprefix $(objtree)/,$(filter-out $(bounds-file) $(offsets-file),$(targets))) | 99 | no-clean-files := $(bounds-file) $(offsets-file) |
| @@ -1137,21 +1137,13 @@ MRPROPER_FILES += .config .config.old .version .old_version \ | |||
| 1137 | # | 1137 | # |
| 1138 | clean: rm-dirs := $(CLEAN_DIRS) | 1138 | clean: rm-dirs := $(CLEAN_DIRS) |
| 1139 | clean: rm-files := $(CLEAN_FILES) | 1139 | clean: rm-files := $(CLEAN_FILES) |
| 1140 | clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs) Documentation) | 1140 | clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation) |
| 1141 | 1141 | ||
| 1142 | PHONY += $(clean-dirs) clean archclean | 1142 | PHONY += $(clean-dirs) clean archclean |
| 1143 | $(clean-dirs): | 1143 | $(clean-dirs): |
| 1144 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) | 1144 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) |
| 1145 | 1145 | ||
| 1146 | clean: archclean $(clean-dirs) | 1146 | clean: archclean |
| 1147 | $(call cmd,rmdirs) | ||
| 1148 | $(call cmd,rmfiles) | ||
| 1149 | @find . $(RCS_FIND_IGNORE) \ | ||
| 1150 | \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ | ||
| 1151 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ | ||
| 1152 | -o -name '*.symtypes' -o -name 'modules.order' \ | ||
| 1153 | -o -name modules.builtin -o -name '.tmp_*.o.*' \ | ||
| 1154 | -o -name '*.gcno' \) -type f -print | xargs rm -f | ||
| 1155 | 1147 | ||
| 1156 | # mrproper - Delete all generated files, including .config | 1148 | # mrproper - Delete all generated files, including .config |
| 1157 | # | 1149 | # |
| @@ -1352,16 +1344,7 @@ $(clean-dirs): | |||
| 1352 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) | 1344 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) |
| 1353 | 1345 | ||
| 1354 | clean: rm-dirs := $(MODVERDIR) | 1346 | clean: rm-dirs := $(MODVERDIR) |
| 1355 | clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers \ | 1347 | clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers |
| 1356 | $(KBUILD_EXTMOD)/modules.order \ | ||
| 1357 | $(KBUILD_EXTMOD)/modules.builtin | ||
| 1358 | clean: $(clean-dirs) | ||
| 1359 | $(call cmd,rmdirs) | ||
| 1360 | $(call cmd,rmfiles) | ||
| 1361 | @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \ | ||
| 1362 | \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ | ||
| 1363 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ | ||
| 1364 | -o -name '*.gcno' \) -type f -print | xargs rm -f | ||
| 1365 | 1348 | ||
| 1366 | help: | 1349 | help: |
| 1367 | @echo ' Building external modules.' | 1350 | @echo ' Building external modules.' |
| @@ -1378,6 +1361,16 @@ prepare: ; | |||
| 1378 | scripts: ; | 1361 | scripts: ; |
| 1379 | endif # KBUILD_EXTMOD | 1362 | endif # KBUILD_EXTMOD |
| 1380 | 1363 | ||
| 1364 | clean: $(clean-dirs) | ||
| 1365 | $(call cmd,rmdirs) | ||
| 1366 | $(call cmd,rmfiles) | ||
| 1367 | @find $(or $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ | ||
| 1368 | \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ | ||
| 1369 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ | ||
| 1370 | -o -name '*.symtypes' -o -name 'modules.order' \ | ||
| 1371 | -o -name modules.builtin -o -name '.tmp_*.o.*' \ | ||
| 1372 | -o -name '*.gcno' \) -type f -print | xargs rm -f | ||
| 1373 | |||
| 1381 | # Generate tags for editors | 1374 | # Generate tags for editors |
| 1382 | # --------------------------------------------------------------------------- | 1375 | # --------------------------------------------------------------------------- |
| 1383 | quiet_cmd_tags = GEN $@ | 1376 | quiet_cmd_tags = GEN $@ |
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 172951bf23a4..dd30e883d4a7 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
| @@ -100,6 +100,14 @@ config REGULATOR_MAX8925 | |||
| 100 | help | 100 | help |
| 101 | Say y here to support the voltage regulaltor of Maxim MAX8925 PMIC. | 101 | Say y here to support the voltage regulaltor of Maxim MAX8925 PMIC. |
| 102 | 102 | ||
| 103 | config REGULATOR_MAX8952 | ||
| 104 | tristate "Maxim MAX8952 Power Management IC" | ||
| 105 | depends on I2C | ||
| 106 | help | ||
| 107 | This driver controls a Maxim 8952 voltage output regulator | ||
| 108 | via I2C bus. Maxim 8952 has one voltage output and supports 4 DVS | ||
| 109 | modes ranging from 0.77V to 1.40V by 0.01V steps. | ||
| 110 | |||
| 103 | config REGULATOR_MAX8998 | 111 | config REGULATOR_MAX8998 |
| 104 | tristate "Maxim 8998 voltage regulator" | 112 | tristate "Maxim 8998 voltage regulator" |
| 105 | depends on MFD_MAX8998 | 113 | depends on MFD_MAX8998 |
| @@ -164,6 +172,13 @@ config REGULATOR_LP3971 | |||
| 164 | Say Y here to support the voltage regulators and convertors | 172 | Say Y here to support the voltage regulators and convertors |
| 165 | on National Semiconductors LP3971 PMIC | 173 | on National Semiconductors LP3971 PMIC |
| 166 | 174 | ||
| 175 | config REGULATOR_LP3972 | ||
| 176 | tristate "National Semiconductors LP3972 PMIC regulator driver" | ||
| 177 | depends on I2C | ||
| 178 | help | ||
| 179 | Say Y here to support the voltage regulators and convertors | ||
| 180 | on National Semiconductors LP3972 PMIC | ||
| 181 | |||
| 167 | config REGULATOR_PCAP | 182 | config REGULATOR_PCAP |
| 168 | tristate "PCAP2 regulator driver" | 183 | tristate "PCAP2 regulator driver" |
| 169 | depends on EZX_PCAP | 184 | depends on EZX_PCAP |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 8285fd832e16..bff815736780 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
| @@ -3,20 +3,21 @@ | |||
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | obj-$(CONFIG_REGULATOR) += core.o | 6 | obj-$(CONFIG_REGULATOR) += core.o dummy.o |
| 7 | obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o | 7 | obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o |
| 8 | obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o | 8 | obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o |
| 9 | obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o | 9 | obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o |
| 10 | 10 | ||
| 11 | obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o | 11 | obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o |
| 12 | obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o | 12 | obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o |
| 13 | obj-$(CONFIG_REGULATOR_DUMMY) += dummy.o | ||
| 14 | obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o | 13 | obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o |
| 14 | obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o | ||
| 15 | obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o | 15 | obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o |
| 16 | obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o | 16 | obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o |
| 17 | obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o | 17 | obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o |
| 18 | obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o | 18 | obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o |
| 19 | obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o | 19 | obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o |
| 20 | obj-$(CONFIG_REGULATOR_MAX8952) += max8952.o | ||
| 20 | obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o | 21 | obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o |
| 21 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o | 22 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o |
| 22 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o | 23 | obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index cc8b337b9119..f1d10c974cd4 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -33,6 +33,7 @@ static DEFINE_MUTEX(regulator_list_mutex); | |||
| 33 | static LIST_HEAD(regulator_list); | 33 | static LIST_HEAD(regulator_list); |
| 34 | static LIST_HEAD(regulator_map_list); | 34 | static LIST_HEAD(regulator_map_list); |
| 35 | static int has_full_constraints; | 35 | static int has_full_constraints; |
| 36 | static bool board_wants_dummy_regulator; | ||
| 36 | 37 | ||
| 37 | /* | 38 | /* |
| 38 | * struct regulator_map | 39 | * struct regulator_map |
| @@ -63,7 +64,8 @@ struct regulator { | |||
| 63 | }; | 64 | }; |
| 64 | 65 | ||
| 65 | static int _regulator_is_enabled(struct regulator_dev *rdev); | 66 | static int _regulator_is_enabled(struct regulator_dev *rdev); |
| 66 | static int _regulator_disable(struct regulator_dev *rdev); | 67 | static int _regulator_disable(struct regulator_dev *rdev, |
| 68 | struct regulator_dev **supply_rdev_ptr); | ||
| 67 | static int _regulator_get_voltage(struct regulator_dev *rdev); | 69 | static int _regulator_get_voltage(struct regulator_dev *rdev); |
| 68 | static int _regulator_get_current_limit(struct regulator_dev *rdev); | 70 | static int _regulator_get_current_limit(struct regulator_dev *rdev); |
| 69 | static unsigned int _regulator_get_mode(struct regulator_dev *rdev); | 71 | static unsigned int _regulator_get_mode(struct regulator_dev *rdev); |
| @@ -1108,6 +1110,11 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, | |||
| 1108 | } | 1110 | } |
| 1109 | } | 1111 | } |
| 1110 | 1112 | ||
| 1113 | if (board_wants_dummy_regulator) { | ||
| 1114 | rdev = dummy_regulator_rdev; | ||
| 1115 | goto found; | ||
| 1116 | } | ||
| 1117 | |||
| 1111 | #ifdef CONFIG_REGULATOR_DUMMY | 1118 | #ifdef CONFIG_REGULATOR_DUMMY |
| 1112 | if (!devname) | 1119 | if (!devname) |
| 1113 | devname = "deviceless"; | 1120 | devname = "deviceless"; |
| @@ -1348,7 +1355,8 @@ int regulator_enable(struct regulator *regulator) | |||
| 1348 | EXPORT_SYMBOL_GPL(regulator_enable); | 1355 | EXPORT_SYMBOL_GPL(regulator_enable); |
| 1349 | 1356 | ||
| 1350 | /* locks held by regulator_disable() */ | 1357 | /* locks held by regulator_disable() */ |
| 1351 | static int _regulator_disable(struct regulator_dev *rdev) | 1358 | static int _regulator_disable(struct regulator_dev *rdev, |
| 1359 | struct regulator_dev **supply_rdev_ptr) | ||
| 1352 | { | 1360 | { |
| 1353 | int ret = 0; | 1361 | int ret = 0; |
| 1354 | 1362 | ||
| @@ -1376,8 +1384,7 @@ static int _regulator_disable(struct regulator_dev *rdev) | |||
| 1376 | } | 1384 | } |
| 1377 | 1385 | ||
| 1378 | /* decrease our supplies ref count and disable if required */ | 1386 | /* decrease our supplies ref count and disable if required */ |
| 1379 | if (rdev->supply) | 1387 | *supply_rdev_ptr = rdev->supply; |
| 1380 | _regulator_disable(rdev->supply); | ||
| 1381 | 1388 | ||
| 1382 | rdev->use_count = 0; | 1389 | rdev->use_count = 0; |
| 1383 | } else if (rdev->use_count > 1) { | 1390 | } else if (rdev->use_count > 1) { |
| @@ -1407,17 +1414,29 @@ static int _regulator_disable(struct regulator_dev *rdev) | |||
| 1407 | int regulator_disable(struct regulator *regulator) | 1414 | int regulator_disable(struct regulator *regulator) |
| 1408 | { | 1415 | { |
| 1409 | struct regulator_dev *rdev = regulator->rdev; | 1416 | struct regulator_dev *rdev = regulator->rdev; |
| 1417 | struct regulator_dev *supply_rdev = NULL; | ||
| 1410 | int ret = 0; | 1418 | int ret = 0; |
| 1411 | 1419 | ||
| 1412 | mutex_lock(&rdev->mutex); | 1420 | mutex_lock(&rdev->mutex); |
| 1413 | ret = _regulator_disable(rdev); | 1421 | ret = _regulator_disable(rdev, &supply_rdev); |
| 1414 | mutex_unlock(&rdev->mutex); | 1422 | mutex_unlock(&rdev->mutex); |
| 1423 | |||
| 1424 | /* decrease our supplies ref count and disable if required */ | ||
| 1425 | while (supply_rdev != NULL) { | ||
| 1426 | rdev = supply_rdev; | ||
| 1427 | |||
| 1428 | mutex_lock(&rdev->mutex); | ||
| 1429 | _regulator_disable(rdev, &supply_rdev); | ||
| 1430 | mutex_unlock(&rdev->mutex); | ||
| 1431 | } | ||
| 1432 | |||
| 1415 | return ret; | 1433 | return ret; |
| 1416 | } | 1434 | } |
| 1417 | EXPORT_SYMBOL_GPL(regulator_disable); | 1435 | EXPORT_SYMBOL_GPL(regulator_disable); |
| 1418 | 1436 | ||
| 1419 | /* locks held by regulator_force_disable() */ | 1437 | /* locks held by regulator_force_disable() */ |
| 1420 | static int _regulator_force_disable(struct regulator_dev *rdev) | 1438 | static int _regulator_force_disable(struct regulator_dev *rdev, |
| 1439 | struct regulator_dev **supply_rdev_ptr) | ||
| 1421 | { | 1440 | { |
| 1422 | int ret = 0; | 1441 | int ret = 0; |
| 1423 | 1442 | ||
| @@ -1436,8 +1455,7 @@ static int _regulator_force_disable(struct regulator_dev *rdev) | |||
| 1436 | } | 1455 | } |
| 1437 | 1456 | ||
| 1438 | /* decrease our supplies ref count and disable if required */ | 1457 | /* decrease our supplies ref count and disable if required */ |
| 1439 | if (rdev->supply) | 1458 | *supply_rdev_ptr = rdev->supply; |
| 1440 | _regulator_disable(rdev->supply); | ||
| 1441 | 1459 | ||
| 1442 | rdev->use_count = 0; | 1460 | rdev->use_count = 0; |
| 1443 | return ret; | 1461 | return ret; |
| @@ -1454,12 +1472,17 @@ static int _regulator_force_disable(struct regulator_dev *rdev) | |||
| 1454 | */ | 1472 | */ |
| 1455 | int regulator_force_disable(struct regulator *regulator) | 1473 | int regulator_force_disable(struct regulator *regulator) |
| 1456 | { | 1474 | { |
| 1475 | struct regulator_dev *supply_rdev = NULL; | ||
| 1457 | int ret; | 1476 | int ret; |
| 1458 | 1477 | ||
| 1459 | mutex_lock(®ulator->rdev->mutex); | 1478 | mutex_lock(®ulator->rdev->mutex); |
| 1460 | regulator->uA_load = 0; | 1479 | regulator->uA_load = 0; |
| 1461 | ret = _regulator_force_disable(regulator->rdev); | 1480 | ret = _regulator_force_disable(regulator->rdev, &supply_rdev); |
| 1462 | mutex_unlock(®ulator->rdev->mutex); | 1481 | mutex_unlock(®ulator->rdev->mutex); |
| 1482 | |||
| 1483 | if (supply_rdev) | ||
| 1484 | regulator_disable(get_device_regulator(rdev_get_dev(supply_rdev))); | ||
| 1485 | |||
| 1463 | return ret; | 1486 | return ret; |
| 1464 | } | 1487 | } |
| 1465 | EXPORT_SYMBOL_GPL(regulator_force_disable); | 1488 | EXPORT_SYMBOL_GPL(regulator_force_disable); |
| @@ -2463,6 +2486,22 @@ void regulator_has_full_constraints(void) | |||
| 2463 | EXPORT_SYMBOL_GPL(regulator_has_full_constraints); | 2486 | EXPORT_SYMBOL_GPL(regulator_has_full_constraints); |
| 2464 | 2487 | ||
| 2465 | /** | 2488 | /** |
| 2489 | * regulator_use_dummy_regulator - Provide a dummy regulator when none is found | ||
| 2490 | * | ||
| 2491 | * Calling this function will cause the regulator API to provide a | ||
| 2492 | * dummy regulator to consumers if no physical regulator is found, | ||
| 2493 | * allowing most consumers to proceed as though a regulator were | ||
| 2494 | * configured. This allows systems such as those with software | ||
| 2495 | * controllable regulators for the CPU core only to be brought up more | ||
| 2496 | * readily. | ||
| 2497 | */ | ||
| 2498 | void regulator_use_dummy_regulator(void) | ||
| 2499 | { | ||
| 2500 | board_wants_dummy_regulator = true; | ||
| 2501 | } | ||
| 2502 | EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator); | ||
| 2503 | |||
| 2504 | /** | ||
| 2466 | * rdev_get_drvdata - get rdev regulator driver data | 2505 | * rdev_get_drvdata - get rdev regulator driver data |
| 2467 | * @rdev: regulator | 2506 | * @rdev: regulator |
| 2468 | * | 2507 | * |
diff --git a/drivers/regulator/dummy.h b/drivers/regulator/dummy.h index 3921c0e24249..97a11b7e8882 100644 --- a/drivers/regulator/dummy.h +++ b/drivers/regulator/dummy.h | |||
| @@ -22,10 +22,6 @@ struct regulator_dev; | |||
| 22 | 22 | ||
| 23 | extern struct regulator_dev *dummy_regulator_rdev; | 23 | extern struct regulator_dev *dummy_regulator_rdev; |
| 24 | 24 | ||
| 25 | #ifdef CONFIG_REGULATOR_DUMMY | ||
| 26 | void __init regulator_dummy_init(void); | 25 | void __init regulator_dummy_init(void); |
| 27 | #else | ||
| 28 | static inline void regulator_dummy_init(void) { } | ||
| 29 | #endif | ||
| 30 | 26 | ||
| 31 | #endif | 27 | #endif |
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c new file mode 100644 index 000000000000..e07062fd0b42 --- /dev/null +++ b/drivers/regulator/lp3972.c | |||
| @@ -0,0 +1,660 @@ | |||
| 1 | /* | ||
| 2 | * Regulator driver for National Semiconductors LP3972 PMIC chip | ||
| 3 | * | ||
| 4 | * Based on lp3971.c | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | * | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/bug.h> | ||
| 13 | #include <linux/err.h> | ||
| 14 | #include <linux/i2c.h> | ||
| 15 | #include <linux/kernel.h> | ||
| 16 | #include <linux/regulator/driver.h> | ||
| 17 | #include <linux/regulator/lp3972.h> | ||
| 18 | #include <linux/slab.h> | ||
| 19 | |||
| 20 | struct lp3972 { | ||
| 21 | struct device *dev; | ||
| 22 | struct mutex io_lock; | ||
| 23 | struct i2c_client *i2c; | ||
| 24 | int num_regulators; | ||
| 25 | struct regulator_dev **rdev; | ||
| 26 | }; | ||
| 27 | |||
| 28 | /* LP3972 Control Registers */ | ||
| 29 | #define LP3972_SCR_REG 0x07 | ||
| 30 | #define LP3972_OVER1_REG 0x10 | ||
| 31 | #define LP3972_OVSR1_REG 0x11 | ||
| 32 | #define LP3972_OVER2_REG 0x12 | ||
| 33 | #define LP3972_OVSR2_REG 0x13 | ||
| 34 | #define LP3972_VCC1_REG 0x20 | ||
| 35 | #define LP3972_ADTV1_REG 0x23 | ||
| 36 | #define LP3972_ADTV2_REG 0x24 | ||
| 37 | #define LP3972_AVRC_REG 0x25 | ||
| 38 | #define LP3972_CDTC1_REG 0x26 | ||
| 39 | #define LP3972_CDTC2_REG 0x27 | ||
| 40 | #define LP3972_SDTV1_REG 0x29 | ||
| 41 | #define LP3972_SDTV2_REG 0x2A | ||
| 42 | #define LP3972_MDTV1_REG 0x32 | ||
| 43 | #define LP3972_MDTV2_REG 0x33 | ||
| 44 | #define LP3972_L2VCR_REG 0x39 | ||
| 45 | #define LP3972_L34VCR_REG 0x3A | ||
| 46 | #define LP3972_SCR1_REG 0x80 | ||
| 47 | #define LP3972_SCR2_REG 0x81 | ||
| 48 | #define LP3972_OEN3_REG 0x82 | ||
| 49 | #define LP3972_OSR3_REG 0x83 | ||
| 50 | #define LP3972_LOER4_REG 0x84 | ||
| 51 | #define LP3972_B2TV_REG 0x85 | ||
| 52 | #define LP3972_B3TV_REG 0x86 | ||
| 53 | #define LP3972_B32RC_REG 0x87 | ||
| 54 | #define LP3972_ISRA_REG 0x88 | ||
| 55 | #define LP3972_BCCR_REG 0x89 | ||
| 56 | #define LP3972_II1RR_REG 0x8E | ||
| 57 | #define LP3972_II2RR_REG 0x8F | ||
| 58 | |||
| 59 | #define LP3972_SYS_CONTROL1_REG LP3972_SCR1_REG | ||
| 60 | /* System control register 1 initial value, | ||
| 61 | * bits 5, 6 and 7 are EPROM programmable */ | ||
| 62 | #define SYS_CONTROL1_INIT_VAL 0x02 | ||
| 63 | #define SYS_CONTROL1_INIT_MASK 0x1F | ||
| 64 | |||
| 65 | #define LP3972_VOL_CHANGE_REG LP3972_VCC1_REG | ||
| 66 | #define LP3972_VOL_CHANGE_FLAG_GO 0x01 | ||
| 67 | #define LP3972_VOL_CHANGE_FLAG_MASK 0x03 | ||
| 68 | |||
| 69 | /* LDO output enable mask */ | ||
| 70 | #define LP3972_OEN3_L1EN BIT(0) | ||
| 71 | #define LP3972_OVER2_LDO2_EN BIT(2) | ||
| 72 | #define LP3972_OVER2_LDO3_EN BIT(3) | ||
| 73 | #define LP3972_OVER2_LDO4_EN BIT(4) | ||
| 74 | #define LP3972_OVER1_S_EN BIT(2) | ||
| 75 | |||
| 76 | static const int ldo1_voltage_map[] = { | ||
| 77 | 1700, 1725, 1750, 1775, 1800, 1825, 1850, 1875, | ||
| 78 | 1900, 1925, 1950, 1975, 2000, | ||
| 79 | }; | ||
| 80 | |||
| 81 | static const int ldo23_voltage_map[] = { | ||
| 82 | 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, | ||
| 83 | 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, | ||
| 84 | }; | ||
| 85 | |||
| 86 | static const int ldo4_voltage_map[] = { | ||
| 87 | 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350, | ||
| 88 | 1400, 1500, 1800, 1900, 2500, 2800, 3000, 3300, | ||
| 89 | }; | ||
| 90 | |||
| 91 | static const int ldo5_voltage_map[] = { | ||
| 92 | 0, 0, 0, 0, 0, 850, 875, 900, | ||
| 93 | 925, 950, 975, 1000, 1025, 1050, 1075, 1100, | ||
| 94 | 1125, 1150, 1175, 1200, 1225, 1250, 1275, 1300, | ||
| 95 | 1325, 1350, 1375, 1400, 1425, 1450, 1475, 1500, | ||
| 96 | }; | ||
| 97 | |||
| 98 | static const int buck1_voltage_map[] = { | ||
| 99 | 725, 750, 775, 800, 825, 850, 875, 900, | ||
| 100 | 925, 950, 975, 1000, 1025, 1050, 1075, 1100, | ||
| 101 | 1125, 1150, 1175, 1200, 1225, 1250, 1275, 1300, | ||
| 102 | 1325, 1350, 1375, 1400, 1425, 1450, 1475, 1500, | ||
| 103 | }; | ||
| 104 | |||
| 105 | static const int buck23_voltage_map[] = { | ||
| 106 | 0, 800, 850, 900, 950, 1000, 1050, 1100, | ||
| 107 | 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500, | ||
| 108 | 1550, 1600, 1650, 1700, 1800, 1900, 2500, 2800, | ||
| 109 | 3000, 3300, | ||
| 110 | }; | ||
| 111 | |||
| 112 | static const int *ldo_voltage_map[] = { | ||
| 113 | ldo1_voltage_map, | ||
| 114 | ldo23_voltage_map, | ||
| 115 | ldo23_voltage_map, | ||
| 116 | ldo4_voltage_map, | ||
| 117 | ldo5_voltage_map, | ||
| 118 | }; | ||
| 119 | |||
| 120 | static const int *buck_voltage_map[] = { | ||
| 121 | buck1_voltage_map, | ||
| 122 | buck23_voltage_map, | ||
| 123 | buck23_voltage_map, | ||
| 124 | }; | ||
| 125 | |||
| 126 | static const int ldo_output_enable_mask[] = { | ||
| 127 | LP3972_OEN3_L1EN, | ||
| 128 | LP3972_OVER2_LDO2_EN, | ||
| 129 | LP3972_OVER2_LDO3_EN, | ||
| 130 | LP3972_OVER2_LDO4_EN, | ||
| 131 | LP3972_OVER1_S_EN, | ||
| 132 | }; | ||
| 133 | |||
| 134 | static const int ldo_output_enable_addr[] = { | ||
| 135 | LP3972_OEN3_REG, | ||
| 136 | LP3972_OVER2_REG, | ||
| 137 | LP3972_OVER2_REG, | ||
| 138 | LP3972_OVER2_REG, | ||
| 139 | LP3972_OVER1_REG, | ||
| 140 | }; | ||
| 141 | |||
| 142 | static const int ldo_vol_ctl_addr[] = { | ||
| 143 | LP3972_MDTV1_REG, | ||
| 144 | LP3972_L2VCR_REG, | ||
| 145 | LP3972_L34VCR_REG, | ||
| 146 | LP3972_L34VCR_REG, | ||
| 147 | LP3972_SDTV1_REG, | ||
| 148 | }; | ||
| 149 | |||
| 150 | static const int buck_vol_enable_addr[] = { | ||
| 151 | LP3972_OVER1_REG, | ||
| 152 | LP3972_OEN3_REG, | ||
| 153 | LP3972_OEN3_REG, | ||
| 154 | }; | ||
| 155 | |||
| 156 | static const int buck_base_addr[] = { | ||
| 157 | LP3972_ADTV1_REG, | ||
| 158 | LP3972_B2TV_REG, | ||
| 159 | LP3972_B3TV_REG, | ||
| 160 | }; | ||
| 161 | |||
| 162 | #define LP3972_LDO_VOL_VALUE_MAP(x) (ldo_voltage_map[x]) | ||
| 163 | #define LP3972_LDO_OUTPUT_ENABLE_MASK(x) (ldo_output_enable_mask[x]) | ||
| 164 | #define LP3972_LDO_OUTPUT_ENABLE_REG(x) (ldo_output_enable_addr[x]) | ||
| 165 | |||
| 166 | /* LDO voltage control registers shift: | ||
| 167 | LP3972_LDO1 -> 0, LP3972_LDO2 -> 4 | ||
| 168 | LP3972_LDO3 -> 0, LP3972_LDO4 -> 4 | ||
| 169 | LP3972_LDO5 -> 0 | ||
| 170 | */ | ||
| 171 | #define LP3972_LDO_VOL_CONTR_SHIFT(x) (((x) & 1) << 2) | ||
| 172 | #define LP3972_LDO_VOL_CONTR_REG(x) (ldo_vol_ctl_addr[x]) | ||
| 173 | #define LP3972_LDO_VOL_CHANGE_SHIFT(x) ((x) ? 4 : 6) | ||
| 174 | |||
| 175 | #define LP3972_LDO_VOL_MASK(x) (((x) % 4) ? 0x0f : 0x1f) | ||
| 176 | #define LP3972_LDO_VOL_MIN_IDX(x) (((x) == 4) ? 0x05 : 0x00) | ||
| 177 | #define LP3972_LDO_VOL_MAX_IDX(x) ((x) ? (((x) == 4) ? 0x1f : 0x0f) : 0x0c) | ||
| 178 | |||
| 179 | #define LP3972_BUCK_VOL_VALUE_MAP(x) (buck_voltage_map[x]) | ||
| 180 | #define LP3972_BUCK_VOL_ENABLE_REG(x) (buck_vol_enable_addr[x]) | ||
| 181 | #define LP3972_BUCK_VOL1_REG(x) (buck_base_addr[x]) | ||
| 182 | #define LP3972_BUCK_VOL_MASK 0x1f | ||
| 183 | #define LP3972_BUCK_VOL_MIN_IDX(x) ((x) ? 0x01 : 0x00) | ||
| 184 | #define LP3972_BUCK_VOL_MAX_IDX(x) ((x) ? 0x19 : 0x1f) | ||
| 185 | |||
| 186 | static int lp3972_i2c_read(struct i2c_client *i2c, char reg, int count, | ||
| 187 | u16 *dest) | ||
| 188 | { | ||
| 189 | int ret; | ||
| 190 | |||
| 191 | if (count != 1) | ||
| 192 | return -EIO; | ||
| 193 | ret = i2c_smbus_read_byte_data(i2c, reg); | ||
| 194 | if (ret < 0) | ||
| 195 | return ret; | ||
| 196 | |||
| 197 | *dest = ret; | ||
| 198 | return 0; | ||
| 199 | } | ||
| 200 | |||
| 201 | static int lp3972_i2c_write(struct i2c_client *i2c, char reg, int count, | ||
| 202 | const u16 *src) | ||
| 203 | { | ||
| 204 | if (count != 1) | ||
| 205 | return -EIO; | ||
| 206 | return i2c_smbus_write_byte_data(i2c, reg, *src); | ||
| 207 | } | ||
| 208 | |||
| 209 | static u8 lp3972_reg_read(struct lp3972 *lp3972, u8 reg) | ||
| 210 | { | ||
| 211 | u16 val = 0; | ||
| 212 | |||
| 213 | mutex_lock(&lp3972->io_lock); | ||
| 214 | |||
| 215 | lp3972_i2c_read(lp3972->i2c, reg, 1, &val); | ||
| 216 | |||
| 217 | dev_dbg(lp3972->dev, "reg read 0x%02x -> 0x%02x\n", (int)reg, | ||
| 218 | (unsigned)val & 0xff); | ||
| 219 | |||
| 220 | mutex_unlock(&lp3972->io_lock); | ||
| 221 | |||
| 222 | return val & 0xff; | ||
| 223 | } | ||
| 224 | |||
| 225 | static int lp3972_set_bits(struct lp3972 *lp3972, u8 reg, u16 mask, u16 val) | ||
| 226 | { | ||
| 227 | u16 tmp; | ||
| 228 | int ret; | ||
| 229 | |||
| 230 | mutex_lock(&lp3972->io_lock); | ||
| 231 | |||
| 232 | ret = lp3972_i2c_read(lp3972->i2c, reg, 1, &tmp); | ||
| 233 | tmp = (tmp & ~mask) | val; | ||
| 234 | if (ret == 0) { | ||
| 235 | ret = lp3972_i2c_write(lp3972->i2c, reg, 1, &tmp); | ||
| 236 | dev_dbg(lp3972->dev, "reg write 0x%02x -> 0x%02x\n", (int)reg, | ||
| 237 | (unsigned)val & 0xff); | ||
| 238 | } | ||
| 239 | mutex_unlock(&lp3972->io_lock); | ||
| 240 | |||
| 241 | return ret; | ||
| 242 | } | ||
| 243 | |||
| 244 | static int lp3972_ldo_list_voltage(struct regulator_dev *dev, unsigned index) | ||
| 245 | { | ||
| 246 | int ldo = rdev_get_id(dev) - LP3972_LDO1; | ||
| 247 | return 1000 * LP3972_LDO_VOL_VALUE_MAP(ldo)[index]; | ||
| 248 | } | ||
| 249 | |||
| 250 | static int lp3972_ldo_is_enabled(struct regulator_dev *dev) | ||
| 251 | { | ||
| 252 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | ||
| 253 | int ldo = rdev_get_id(dev) - LP3972_LDO1; | ||
| 254 | u16 mask = LP3972_LDO_OUTPUT_ENABLE_MASK(ldo); | ||
| 255 | u16 val; | ||
| 256 | |||
| 257 | val = lp3972_reg_read(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo)); | ||
| 258 | return !!(val & mask); | ||
| 259 | } | ||
| 260 | |||
| 261 | static int lp3972_ldo_enable(struct regulator_dev *dev) | ||
| 262 | { | ||
| 263 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | ||
| 264 | int ldo = rdev_get_id(dev) - LP3972_LDO1; | ||
| 265 | u16 mask = LP3972_LDO_OUTPUT_ENABLE_MASK(ldo); | ||
| 266 | |||
| 267 | return lp3972_set_bits(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo), | ||
| 268 | mask, mask); | ||
| 269 | } | ||
| 270 | |||
| 271 | static int lp3972_ldo_disable(struct regulator_dev *dev) | ||
| 272 | { | ||
| 273 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | ||
| 274 | int ldo = rdev_get_id(dev) - LP3972_LDO1; | ||
| 275 | u16 mask = LP3972_LDO_OUTPUT_ENABLE_MASK(ldo); | ||
| 276 | |||
| 277 | return lp3972_set_bits(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo), | ||
| 278 | mask, 0); | ||
| 279 | } | ||
| 280 | |||
| 281 | static int lp3972_ldo_get_voltage(struct regulator_dev *dev) | ||
| 282 | { | ||
| 283 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | ||
| 284 | int ldo = rdev_get_id(dev) - LP3972_LDO1; | ||
| 285 | u16 mask = LP3972_LDO_VOL_MASK(ldo); | ||
| 286 | u16 val, reg; | ||
| 287 | |||
| 288 | reg = lp3972_reg_read(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo)); | ||
| 289 | val = (reg >> LP3972_LDO_VOL_CONTR_SHIFT(ldo)) & mask; | ||
| 290 | |||
| 291 | return 1000 * LP3972_LDO_VOL_VALUE_MAP(ldo)[val]; | ||
| 292 | } | ||
| 293 | |||
| 294 | static int lp3972_ldo_set_voltage(struct regulator_dev *dev, | ||
| 295 | int min_uV, int max_uV) | ||
| 296 | { | ||
| 297 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | ||
| 298 | int ldo = rdev_get_id(dev) - LP3972_LDO1; | ||
| 299 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; | ||
| 300 | const int *vol_map = LP3972_LDO_VOL_VALUE_MAP(ldo); | ||
| 301 | u16 val; | ||
| 302 | int shift, ret; | ||
| 303 | |||
| 304 | if (min_vol < vol_map[LP3972_LDO_VOL_MIN_IDX(ldo)] || | ||
| 305 | min_vol > vol_map[LP3972_LDO_VOL_MAX_IDX(ldo)]) | ||
| 306 | return -EINVAL; | ||
| 307 | |||
| 308 | for (val = LP3972_LDO_VOL_MIN_IDX(ldo); | ||
| 309 | val <= LP3972_LDO_VOL_MAX_IDX(ldo); val++) | ||
| 310 | if (vol_map[val] >= min_vol) | ||
| 311 | break; | ||
| 312 | |||
| 313 | if (val > LP3972_LDO_VOL_MAX_IDX(ldo) || vol_map[val] > max_vol) | ||
| 314 | return -EINVAL; | ||
| 315 | |||
| 316 | shift = LP3972_LDO_VOL_CONTR_SHIFT(ldo); | ||
| 317 | ret = lp3972_set_bits(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo), | ||
| 318 | LP3972_LDO_VOL_MASK(ldo) << shift, val << shift); | ||
| 319 | |||
| 320 | if (ret) | ||
| 321 | return ret; | ||
| 322 | |||
| 323 | /* | ||
| 324 | * LDO1 and LDO5 support voltage control by either target voltage1 | ||
| 325 | * or target voltage2 register. | ||
| 326 | * We use target voltage1 register for LDO1 and LDO5 in this driver. | ||
| 327 | * We need to update voltage change control register(0x20) to enable | ||
| 328 | * LDO1 and LDO5 to change to their programmed target values. | ||
| 329 | */ | ||
| 330 | switch (ldo) { | ||
| 331 | case LP3972_LDO1: | ||
| 332 | case LP3972_LDO5: | ||
| 333 | shift = LP3972_LDO_VOL_CHANGE_SHIFT(ldo); | ||
| 334 | ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG, | ||
| 335 | LP3972_VOL_CHANGE_FLAG_MASK << shift, | ||
| 336 | LP3972_VOL_CHANGE_FLAG_GO << shift); | ||
| 337 | if (ret) | ||
| 338 | return ret; | ||
| 339 | |||
| 340 | ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG, | ||
| 341 | LP3972_VOL_CHANGE_FLAG_MASK << shift, 0); | ||
| 342 | break; | ||
| 343 | } | ||
| 344 | |||
| 345 | return ret; | ||
| 346 | } | ||
| 347 | |||
| 348 | static struct regulator_ops lp3972_ldo_ops = { | ||
| 349 | .list_voltage = lp3972_ldo_list_voltage, | ||
| 350 | .is_enabled = lp3972_ldo_is_enabled, | ||
| 351 | .enable = lp3972_ldo_enable, | ||
| 352 | .disable = lp3972_ldo_disable, | ||
| 353 | .get_voltage = lp3972_ldo_get_voltage, | ||
| 354 | .set_voltage = lp3972_ldo_set_voltage, | ||
| 355 | }; | ||
| 356 | |||
| 357 | static int lp3972_dcdc_list_voltage(struct regulator_dev *dev, unsigned index) | ||
| 358 | { | ||
| 359 | int buck = rdev_get_id(dev) - LP3972_DCDC1; | ||
| 360 | return 1000 * buck_voltage_map[buck][index]; | ||
| 361 | } | ||
| 362 | |||
| 363 | static int lp3972_dcdc_is_enabled(struct regulator_dev *dev) | ||
| 364 | { | ||
| 365 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | ||
| 366 | int buck = rdev_get_id(dev) - LP3972_DCDC1; | ||
| 367 | u16 mask = 1 << (buck * 2); | ||
| 368 | u16 val; | ||
| 369 | |||
| 370 | val = lp3972_reg_read(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck)); | ||
| 371 | return !!(val & mask); | ||
| 372 | } | ||
| 373 | |||
| 374 | static int lp3972_dcdc_enable(struct regulator_dev *dev) | ||
| 375 | { | ||
| 376 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | ||
| 377 | int buck = rdev_get_id(dev) - LP3972_DCDC1; | ||
| 378 | u16 mask = 1 << (buck * 2); | ||
| 379 | u16 val; | ||
| 380 | |||
| 381 | val = lp3972_set_bits(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck), | ||
| 382 | mask, mask); | ||
| 383 | return val; | ||
| 384 | } | ||
| 385 | |||
| 386 | static int lp3972_dcdc_disable(struct regulator_dev *dev) | ||
| 387 | { | ||
| 388 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | ||
| 389 | int buck = rdev_get_id(dev) - LP3972_DCDC1; | ||
| 390 | u16 mask = 1 << (buck * 2); | ||
| 391 | u16 val; | ||
| 392 | |||
| 393 | val = lp3972_set_bits(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck), | ||
| 394 | mask, 0); | ||
| 395 | return val; | ||
| 396 | } | ||
| 397 | |||
| 398 | static int lp3972_dcdc_get_voltage(struct regulator_dev *dev) | ||
| 399 | { | ||
| 400 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | ||
| 401 | int buck = rdev_get_id(dev) - LP3972_DCDC1; | ||
| 402 | u16 reg; | ||
| 403 | int val; | ||
| 404 | |||
| 405 | reg = lp3972_reg_read(lp3972, LP3972_BUCK_VOL1_REG(buck)); | ||
| 406 | reg &= LP3972_BUCK_VOL_MASK; | ||
| 407 | if (reg <= LP3972_BUCK_VOL_MAX_IDX(buck)) | ||
| 408 | val = 1000 * buck_voltage_map[buck][reg]; | ||
| 409 | else { | ||
| 410 | val = 0; | ||
| 411 | dev_warn(&dev->dev, "chip reported incorrect voltage value." | ||
| 412 | " reg = %d\n", reg); | ||
| 413 | } | ||
| 414 | |||
| 415 | return val; | ||
| 416 | } | ||
| 417 | |||
| 418 | static int lp3972_dcdc_set_voltage(struct regulator_dev *dev, | ||
| 419 | int min_uV, int max_uV) | ||
| 420 | { | ||
| 421 | struct lp3972 *lp3972 = rdev_get_drvdata(dev); | ||
| 422 | int buck = rdev_get_id(dev) - LP3972_DCDC1; | ||
| 423 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; | ||
| 424 | const int *vol_map = buck_voltage_map[buck]; | ||
| 425 | u16 val; | ||
| 426 | int ret; | ||
| 427 | |||
| 428 | if (min_vol < vol_map[LP3972_BUCK_VOL_MIN_IDX(buck)] || | ||
| 429 | min_vol > vol_map[LP3972_BUCK_VOL_MAX_IDX(buck)]) | ||
| 430 | return -EINVAL; | ||
| 431 | |||
| 432 | for (val = LP3972_BUCK_VOL_MIN_IDX(buck); | ||
| 433 | val <= LP3972_BUCK_VOL_MAX_IDX(buck); val++) | ||
| 434 | if (vol_map[val] >= min_vol) | ||
| 435 | break; | ||
| 436 | |||
| 437 | if (val > LP3972_BUCK_VOL_MAX_IDX(buck) || | ||
| 438 | vol_map[val] > max_vol) | ||
| 439 | return -EINVAL; | ||
| 440 | |||
| 441 | ret = lp3972_set_bits(lp3972, LP3972_BUCK_VOL1_REG(buck), | ||
| 442 | LP3972_BUCK_VOL_MASK, val); | ||
| 443 | if (ret) | ||
| 444 | return ret; | ||
| 445 | |||
| 446 | if (buck != 0) | ||
| 447 | return ret; | ||
| 448 | |||
| 449 | ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG, | ||
| 450 | LP3972_VOL_CHANGE_FLAG_MASK, LP3972_VOL_CHANGE_FLAG_GO); | ||
| 451 | if (ret) | ||
| 452 | return ret; | ||
| 453 | |||
| 454 | return lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG, | ||
| 455 | LP3972_VOL_CHANGE_FLAG_MASK, 0); | ||
| 456 | } | ||
| 457 | |||
| 458 | static struct regulator_ops lp3972_dcdc_ops = { | ||
| 459 | .list_voltage = lp3972_dcdc_list_voltage, | ||
| 460 | .is_enabled = lp3972_dcdc_is_enabled, | ||
| 461 | .enable = lp3972_dcdc_enable, | ||
| 462 | .disable = lp3972_dcdc_disable, | ||
| 463 | .get_voltage = lp3972_dcdc_get_voltage, | ||
| 464 | .set_voltage = lp3972_dcdc_set_voltage, | ||
| 465 | }; | ||
| 466 | |||
| 467 | static struct regulator_desc regulators[] = { | ||
| 468 | { | ||
| 469 | .name = "LDO1", | ||
| 470 | .id = LP3972_LDO1, | ||
| 471 | .ops = &lp3972_ldo_ops, | ||
| 472 | .n_voltages = ARRAY_SIZE(ldo1_voltage_map), | ||
| 473 | .type = REGULATOR_VOLTAGE, | ||
| 474 | .owner = THIS_MODULE, | ||
| 475 | }, | ||
| 476 | { | ||
| 477 | .name = "LDO2", | ||
| 478 | .id = LP3972_LDO2, | ||
| 479 | .ops = &lp3972_ldo_ops, | ||
| 480 | .n_voltages = ARRAY_SIZE(ldo23_voltage_map), | ||
| 481 | .type = REGULATOR_VOLTAGE, | ||
| 482 | .owner = THIS_MODULE, | ||
| 483 | }, | ||
| 484 | { | ||
| 485 | .name = "LDO3", | ||
| 486 | .id = LP3972_LDO3, | ||
| 487 | .ops = &lp3972_ldo_ops, | ||
| 488 | .n_voltages = ARRAY_SIZE(ldo23_voltage_map), | ||
| 489 | .type = REGULATOR_VOLTAGE, | ||
| 490 | .owner = THIS_MODULE, | ||
| 491 | }, | ||
| 492 | { | ||
| 493 | .name = "LDO4", | ||
| 494 | .id = LP3972_LDO4, | ||
| 495 | .ops = &lp3972_ldo_ops, | ||
| 496 | .n_voltages = ARRAY_SIZE(ldo4_voltage_map), | ||
| 497 | .type = REGULATOR_VOLTAGE, | ||
| 498 | .owner = THIS_MODULE, | ||
| 499 | }, | ||
| 500 | { | ||
| 501 | .name = "LDO5", | ||
| 502 | .id = LP3972_LDO5, | ||
| 503 | .ops = &lp3972_ldo_ops, | ||
| 504 | .n_voltages = ARRAY_SIZE(ldo5_voltage_map), | ||
| 505 | .type = REGULATOR_VOLTAGE, | ||
| 506 | .owner = THIS_MODULE, | ||
| 507 | }, | ||
| 508 | { | ||
| 509 | .name = "DCDC1", | ||
| 510 | .id = LP3972_DCDC1, | ||
| 511 | .ops = &lp3972_dcdc_ops, | ||
| 512 | .n_voltages = ARRAY_SIZE(buck1_voltage_map), | ||
| 513 | .type = REGULATOR_VOLTAGE, | ||
| 514 | .owner = THIS_MODULE, | ||
| 515 | }, | ||
| 516 | { | ||
| 517 | .name = "DCDC2", | ||
| 518 | .id = LP3972_DCDC2, | ||
| 519 | .ops = &lp3972_dcdc_ops, | ||
| 520 | .n_voltages = ARRAY_SIZE(buck23_voltage_map), | ||
| 521 | .type = REGULATOR_VOLTAGE, | ||
| 522 | .owner = THIS_MODULE, | ||
| 523 | }, | ||
| 524 | { | ||
| 525 | .name = "DCDC3", | ||
| 526 | .id = LP3972_DCDC3, | ||
| 527 | .ops = &lp3972_dcdc_ops, | ||
| 528 | .n_voltages = ARRAY_SIZE(buck23_voltage_map), | ||
| 529 | .type = REGULATOR_VOLTAGE, | ||
| 530 | .owner = THIS_MODULE, | ||
| 531 | }, | ||
| 532 | }; | ||
| 533 | |||
| 534 | static int __devinit setup_regulators(struct lp3972 *lp3972, | ||
| 535 | struct lp3972_platform_data *pdata) | ||
| 536 | { | ||
| 537 | int i, err; | ||
| 538 | |||
| 539 | lp3972->num_regulators = pdata->num_regulators; | ||
| 540 | lp3972->rdev = kcalloc(pdata->num_regulators, | ||
| 541 | sizeof(struct regulator_dev *), GFP_KERNEL); | ||
| 542 | if (!lp3972->rdev) { | ||
| 543 | err = -ENOMEM; | ||
| 544 | goto err_nomem; | ||
| 545 | } | ||
| 546 | |||
| 547 | /* Instantiate the regulators */ | ||
| 548 | for (i = 0; i < pdata->num_regulators; i++) { | ||
| 549 | struct lp3972_regulator_subdev *reg = &pdata->regulators[i]; | ||
| 550 | lp3972->rdev[i] = regulator_register(®ulators[reg->id], | ||
| 551 | lp3972->dev, reg->initdata, lp3972); | ||
| 552 | |||
| 553 | if (IS_ERR(lp3972->rdev[i])) { | ||
| 554 | err = PTR_ERR(lp3972->rdev[i]); | ||
| 555 | dev_err(lp3972->dev, "regulator init failed: %d\n", | ||
| 556 | err); | ||
| 557 | goto error; | ||
| 558 | } | ||
| 559 | } | ||
| 560 | |||
| 561 | return 0; | ||
| 562 | error: | ||
| 563 | while (--i >= 0) | ||
| 564 | regulator_unregister(lp3972->rdev[i]); | ||
| 565 | kfree(lp3972->rdev); | ||
| 566 | lp3972->rdev = NULL; | ||
| 567 | err_nomem: | ||
| 568 | return err; | ||
| 569 | } | ||
| 570 | |||
| 571 | static int __devinit lp3972_i2c_probe(struct i2c_client *i2c, | ||
| 572 | const struct i2c_device_id *id) | ||
| 573 | { | ||
| 574 | struct lp3972 *lp3972; | ||
| 575 | struct lp3972_platform_data *pdata = i2c->dev.platform_data; | ||
| 576 | int ret; | ||
| 577 | u16 val; | ||
| 578 | |||
| 579 | if (!pdata) { | ||
| 580 | dev_dbg(&i2c->dev, "No platform init data supplied\n"); | ||
| 581 | return -ENODEV; | ||
| 582 | } | ||
| 583 | |||
| 584 | lp3972 = kzalloc(sizeof(struct lp3972), GFP_KERNEL); | ||
| 585 | if (!lp3972) | ||
| 586 | return -ENOMEM; | ||
| 587 | |||
| 588 | lp3972->i2c = i2c; | ||
| 589 | lp3972->dev = &i2c->dev; | ||
| 590 | |||
| 591 | mutex_init(&lp3972->io_lock); | ||
| 592 | |||
| 593 | /* Detect LP3972 */ | ||
| 594 | ret = lp3972_i2c_read(i2c, LP3972_SYS_CONTROL1_REG, 1, &val); | ||
| 595 | if (ret == 0 && | ||
| 596 | (val & SYS_CONTROL1_INIT_MASK) != SYS_CONTROL1_INIT_VAL) { | ||
| 597 | ret = -ENODEV; | ||
| 598 | dev_err(&i2c->dev, "chip reported: val = 0x%x\n", val); | ||
| 599 | } | ||
| 600 | if (ret < 0) { | ||
| 601 | dev_err(&i2c->dev, "failed to detect device. ret = %d\n", ret); | ||
| 602 | goto err_detect; | ||
| 603 | } | ||
| 604 | |||
| 605 | ret = setup_regulators(lp3972, pdata); | ||
| 606 | if (ret < 0) | ||
| 607 | goto err_detect; | ||
| 608 | |||
| 609 | i2c_set_clientdata(i2c, lp3972); | ||
| 610 | return 0; | ||
| 611 | |||
| 612 | err_detect: | ||
| 613 | kfree(lp3972); | ||
| 614 | return ret; | ||
| 615 | } | ||
| 616 | |||
| 617 | static int __devexit lp3972_i2c_remove(struct i2c_client *i2c) | ||
| 618 | { | ||
| 619 | struct lp3972 *lp3972 = i2c_get_clientdata(i2c); | ||
| 620 | int i; | ||
| 621 | |||
| 622 | for (i = 0; i < lp3972->num_regulators; i++) | ||
| 623 | regulator_unregister(lp3972->rdev[i]); | ||
| 624 | kfree(lp3972->rdev); | ||
| 625 | kfree(lp3972); | ||
| 626 | |||
| 627 | return 0; | ||
| 628 | } | ||
| 629 | |||
| 630 | static const struct i2c_device_id lp3972_i2c_id[] = { | ||
| 631 | { "lp3972", 0 }, | ||
| 632 | { } | ||
| 633 | }; | ||
| 634 | MODULE_DEVICE_TABLE(i2c, lp3972_i2c_id); | ||
| 635 | |||
| 636 | static struct i2c_driver lp3972_i2c_driver = { | ||
| 637 | .driver = { | ||
| 638 | .name = "lp3972", | ||
| 639 | .owner = THIS_MODULE, | ||
| 640 | }, | ||
| 641 | .probe = lp3972_i2c_probe, | ||
| 642 | .remove = __devexit_p(lp3972_i2c_remove), | ||
| 643 | .id_table = lp3972_i2c_id, | ||
| 644 | }; | ||
| 645 | |||
| 646 | static int __init lp3972_module_init(void) | ||
| 647 | { | ||
| 648 | return i2c_add_driver(&lp3972_i2c_driver); | ||
| 649 | } | ||
| 650 | subsys_initcall(lp3972_module_init); | ||
| 651 | |||
| 652 | static void __exit lp3972_module_exit(void) | ||
| 653 | { | ||
| 654 | i2c_del_driver(&lp3972_i2c_driver); | ||
| 655 | } | ||
| 656 | module_exit(lp3972_module_exit); | ||
| 657 | |||
| 658 | MODULE_LICENSE("GPL"); | ||
| 659 | MODULE_AUTHOR("Axel Lin <axel.lin@gmail.com>"); | ||
| 660 | MODULE_DESCRIPTION("LP3972 PMIC driver"); | ||
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c new file mode 100644 index 000000000000..0d5dda4fd911 --- /dev/null +++ b/drivers/regulator/max8952.c | |||
| @@ -0,0 +1,366 @@ | |||
| 1 | /* | ||
| 2 | * max8952.c - Voltage and current regulation for the Maxim 8952 | ||
| 3 | * | ||
| 4 | * Copyright (C) 2010 Samsung Electronics | ||
| 5 | * MyungJoo Ham <myungjoo.ham@samsung.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/init.h> | ||
| 24 | #include <linux/i2c.h> | ||
| 25 | #include <linux/err.h> | ||
| 26 | #include <linux/platform_device.h> | ||
| 27 | #include <linux/regulator/driver.h> | ||
| 28 | #include <linux/regulator/max8952.h> | ||
| 29 | #include <linux/mutex.h> | ||
| 30 | #include <linux/gpio.h> | ||
| 31 | #include <linux/io.h> | ||
| 32 | #include <linux/slab.h> | ||
| 33 | |||
| 34 | /* Registers */ | ||
| 35 | enum { | ||
| 36 | MAX8952_REG_MODE0, | ||
| 37 | MAX8952_REG_MODE1, | ||
| 38 | MAX8952_REG_MODE2, | ||
| 39 | MAX8952_REG_MODE3, | ||
| 40 | MAX8952_REG_CONTROL, | ||
| 41 | MAX8952_REG_SYNC, | ||
| 42 | MAX8952_REG_RAMP, | ||
| 43 | MAX8952_REG_CHIP_ID1, | ||
| 44 | MAX8952_REG_CHIP_ID2, | ||
| 45 | }; | ||
| 46 | |||
| 47 | struct max8952_data { | ||
| 48 | struct i2c_client *client; | ||
| 49 | struct device *dev; | ||
| 50 | struct mutex mutex; | ||
| 51 | struct max8952_platform_data *pdata; | ||
| 52 | struct regulator_dev *rdev; | ||
| 53 | |||
| 54 | bool vid0; | ||
| 55 | bool vid1; | ||
| 56 | bool en; | ||
| 57 | }; | ||
| 58 | |||
| 59 | static int max8952_read_reg(struct max8952_data *max8952, u8 reg) | ||
| 60 | { | ||
| 61 | int ret = i2c_smbus_read_byte_data(max8952->client, reg); | ||
| 62 | if (ret > 0) | ||
| 63 | ret &= 0xff; | ||
| 64 | |||
| 65 | return ret; | ||
| 66 | } | ||
| 67 | |||
| 68 | static int max8952_write_reg(struct max8952_data *max8952, | ||
| 69 | u8 reg, u8 value) | ||
| 70 | { | ||
| 71 | return i2c_smbus_write_byte_data(max8952->client, reg, value); | ||
| 72 | } | ||
| 73 | |||
| 74 | static int max8952_voltage(struct max8952_data *max8952, u8 mode) | ||
| 75 | { | ||
| 76 | return (max8952->pdata->dvs_mode[mode] * 10 + 770) * 1000; | ||
| 77 | } | ||
| 78 | |||
| 79 | static int max8952_list_voltage(struct regulator_dev *rdev, | ||
| 80 | unsigned int selector) | ||
| 81 | { | ||
| 82 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | ||
| 83 | |||
| 84 | if (rdev_get_id(rdev) != 0) | ||
| 85 | return -EINVAL; | ||
| 86 | |||
| 87 | return max8952_voltage(max8952, selector); | ||
| 88 | } | ||
| 89 | |||
| 90 | static int max8952_is_enabled(struct regulator_dev *rdev) | ||
| 91 | { | ||
| 92 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | ||
| 93 | return max8952->en; | ||
| 94 | } | ||
| 95 | |||
| 96 | static int max8952_enable(struct regulator_dev *rdev) | ||
| 97 | { | ||
| 98 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | ||
| 99 | |||
| 100 | /* If not valid, assume "ALWAYS_HIGH" */ | ||
| 101 | if (gpio_is_valid(max8952->pdata->gpio_en)) | ||
| 102 | gpio_set_value(max8952->pdata->gpio_en, 1); | ||
| 103 | |||
| 104 | max8952->en = true; | ||
| 105 | return 0; | ||
| 106 | } | ||
| 107 | |||
| 108 | static int max8952_disable(struct regulator_dev *rdev) | ||
| 109 | { | ||
| 110 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | ||
| 111 | |||
| 112 | /* If not valid, assume "ALWAYS_HIGH" -> not permitted */ | ||
| 113 | if (gpio_is_valid(max8952->pdata->gpio_en)) | ||
| 114 | gpio_set_value(max8952->pdata->gpio_en, 0); | ||
| 115 | else | ||
| 116 | return -EPERM; | ||
| 117 | |||
| 118 | max8952->en = false; | ||
| 119 | return 0; | ||
| 120 | } | ||
| 121 | |||
| 122 | static int max8952_get_voltage(struct regulator_dev *rdev) | ||
| 123 | { | ||
| 124 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | ||
| 125 | u8 vid = 0; | ||
| 126 | |||
| 127 | if (max8952->vid0) | ||
| 128 | vid += 1; | ||
| 129 | if (max8952->vid1) | ||
| 130 | vid += 2; | ||
| 131 | |||
| 132 | return max8952_voltage(max8952, vid); | ||
| 133 | } | ||
| 134 | |||
| 135 | static int max8952_set_voltage(struct regulator_dev *rdev, | ||
| 136 | int min_uV, int max_uV) | ||
| 137 | { | ||
| 138 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | ||
| 139 | s8 vid = -1, i; | ||
| 140 | |||
| 141 | if (!gpio_is_valid(max8952->pdata->gpio_vid0) || | ||
| 142 | !gpio_is_valid(max8952->pdata->gpio_vid0)) { | ||
| 143 | /* DVS not supported */ | ||
| 144 | return -EPERM; | ||
| 145 | } | ||
| 146 | |||
| 147 | for (i = 0; i < MAX8952_NUM_DVS_MODE; i++) { | ||
| 148 | int volt = max8952_voltage(max8952, i); | ||
| 149 | |||
| 150 | /* Set the voltage as low as possible within the range */ | ||
| 151 | if (volt <= max_uV && volt >= min_uV) | ||
| 152 | if (vid == -1 || max8952_voltage(max8952, vid) > volt) | ||
| 153 | vid = i; | ||
| 154 | } | ||
| 155 | |||
| 156 | if (vid >= 0 && vid < MAX8952_NUM_DVS_MODE) { | ||
| 157 | max8952->vid0 = (vid % 2 == 1); | ||
| 158 | max8952->vid1 = (((vid >> 1) % 2) == 1); | ||
| 159 | gpio_set_value(max8952->pdata->gpio_vid0, max8952->vid0); | ||
| 160 | gpio_set_value(max8952->pdata->gpio_vid1, max8952->vid1); | ||
| 161 | } else | ||
| 162 | return -EINVAL; | ||
| 163 | |||
| 164 | return 0; | ||
| 165 | } | ||
| 166 | |||
| 167 | static struct regulator_ops max8952_ops = { | ||
| 168 | .list_voltage = max8952_list_voltage, | ||
| 169 | .is_enabled = max8952_is_enabled, | ||
| 170 | .enable = max8952_enable, | ||
| 171 | .disable = max8952_disable, | ||
| 172 | .get_voltage = max8952_get_voltage, | ||
| 173 | .set_voltage = max8952_set_voltage, | ||
| 174 | .set_suspend_disable = max8952_disable, | ||
| 175 | }; | ||
| 176 | |||
| 177 | static struct regulator_desc regulator = { | ||
| 178 | .name = "MAX8952_VOUT", | ||
| 179 | .id = 0, | ||
| 180 | .n_voltages = MAX8952_NUM_DVS_MODE, | ||
| 181 | .ops = &max8952_ops, | ||
| 182 | .type = REGULATOR_VOLTAGE, | ||
| 183 | .owner = THIS_MODULE, | ||
| 184 | }; | ||
| 185 | |||
| 186 | static int __devinit max8952_pmic_probe(struct i2c_client *client, | ||
| 187 | const struct i2c_device_id *i2c_id) | ||
| 188 | { | ||
| 189 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | ||
| 190 | struct max8952_platform_data *pdata = client->dev.platform_data; | ||
| 191 | struct max8952_data *max8952; | ||
| 192 | |||
| 193 | int ret = 0, err = 0; | ||
| 194 | |||
| 195 | if (!pdata) { | ||
| 196 | dev_err(&client->dev, "Require the platform data\n"); | ||
| 197 | return -EINVAL; | ||
| 198 | } | ||
| 199 | |||
| 200 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) | ||
| 201 | return -EIO; | ||
| 202 | |||
| 203 | max8952 = kzalloc(sizeof(struct max8952_data), GFP_KERNEL); | ||
| 204 | if (!max8952) | ||
| 205 | return -ENOMEM; | ||
| 206 | |||
| 207 | max8952->client = client; | ||
| 208 | max8952->dev = &client->dev; | ||
| 209 | max8952->pdata = pdata; | ||
| 210 | mutex_init(&max8952->mutex); | ||
| 211 | |||
| 212 | max8952->rdev = regulator_register(®ulator, max8952->dev, | ||
| 213 | &pdata->reg_data, max8952); | ||
| 214 | |||
| 215 | if (IS_ERR(max8952->rdev)) { | ||
| 216 | ret = PTR_ERR(max8952->rdev); | ||
| 217 | dev_err(max8952->dev, "regulator init failed (%d)\n", ret); | ||
| 218 | goto err_reg; | ||
| 219 | } | ||
| 220 | |||
| 221 | max8952->en = !!(pdata->reg_data.constraints.boot_on); | ||
| 222 | max8952->vid0 = (pdata->default_mode % 2) == 1; | ||
| 223 | max8952->vid1 = ((pdata->default_mode >> 1) % 2) == 1; | ||
| 224 | |||
| 225 | if (gpio_is_valid(pdata->gpio_en)) { | ||
| 226 | if (!gpio_request(pdata->gpio_en, "MAX8952 EN")) | ||
| 227 | gpio_direction_output(pdata->gpio_en, max8952->en); | ||
| 228 | else | ||
| 229 | err = 1; | ||
| 230 | } else | ||
| 231 | err = 2; | ||
| 232 | |||
| 233 | if (err) { | ||
| 234 | dev_info(max8952->dev, "EN gpio invalid: assume that EN" | ||
| 235 | "is always High\n"); | ||
| 236 | max8952->en = 1; | ||
| 237 | pdata->gpio_en = -1; /* Mark invalid */ | ||
| 238 | } | ||
| 239 | |||
| 240 | err = 0; | ||
| 241 | |||
| 242 | if (gpio_is_valid(pdata->gpio_vid0) && | ||
| 243 | gpio_is_valid(pdata->gpio_vid1)) { | ||
| 244 | if (!gpio_request(pdata->gpio_vid0, "MAX8952 VID0")) | ||
| 245 | gpio_direction_output(pdata->gpio_vid0, | ||
| 246 | (pdata->default_mode) % 2); | ||
| 247 | else | ||
| 248 | err = 1; | ||
| 249 | |||
| 250 | if (!gpio_request(pdata->gpio_vid1, "MAX8952 VID1")) | ||
| 251 | gpio_direction_output(pdata->gpio_vid1, | ||
| 252 | (pdata->default_mode >> 1) % 2); | ||
| 253 | else { | ||
| 254 | if (!err) | ||
| 255 | gpio_free(pdata->gpio_vid0); | ||
| 256 | err = 2; | ||
| 257 | } | ||
| 258 | |||
| 259 | } else | ||
| 260 | err = 3; | ||
| 261 | |||
| 262 | if (err) { | ||
| 263 | dev_warn(max8952->dev, "VID0/1 gpio invalid: " | ||
| 264 | "DVS not avilable.\n"); | ||
| 265 | max8952->vid0 = 0; | ||
| 266 | max8952->vid1 = 0; | ||
| 267 | /* Mark invalid */ | ||
| 268 | pdata->gpio_vid0 = -1; | ||
| 269 | pdata->gpio_vid1 = -1; | ||
| 270 | |||
| 271 | /* Disable Pulldown of EN only */ | ||
| 272 | max8952_write_reg(max8952, MAX8952_REG_CONTROL, 0x60); | ||
| 273 | |||
| 274 | dev_err(max8952->dev, "DVS modes disabled because VID0 and VID1" | ||
| 275 | " do not have proper controls.\n"); | ||
| 276 | } else { | ||
| 277 | /* | ||
| 278 | * Disable Pulldown on EN, VID0, VID1 to reduce | ||
| 279 | * leakage current of MAX8952 assuming that MAX8952 | ||
| 280 | * is turned on (EN==1). Note that without having VID0/1 | ||
| 281 | * properly connected, turning pulldown off can be | ||
| 282 | * problematic. Thus, turn this off only when they are | ||
| 283 | * controllable by GPIO. | ||
| 284 | */ | ||
| 285 | max8952_write_reg(max8952, MAX8952_REG_CONTROL, 0x0); | ||
| 286 | } | ||
| 287 | |||
| 288 | max8952_write_reg(max8952, MAX8952_REG_MODE0, | ||
| 289 | (max8952_read_reg(max8952, | ||
| 290 | MAX8952_REG_MODE0) & 0xC0) | | ||
| 291 | (pdata->dvs_mode[0] & 0x3F)); | ||
| 292 | max8952_write_reg(max8952, MAX8952_REG_MODE1, | ||
| 293 | (max8952_read_reg(max8952, | ||
| 294 | MAX8952_REG_MODE1) & 0xC0) | | ||
| 295 | (pdata->dvs_mode[1] & 0x3F)); | ||
| 296 | max8952_write_reg(max8952, MAX8952_REG_MODE2, | ||
| 297 | (max8952_read_reg(max8952, | ||
| 298 | MAX8952_REG_MODE2) & 0xC0) | | ||
| 299 | (pdata->dvs_mode[2] & 0x3F)); | ||
| 300 | max8952_write_reg(max8952, MAX8952_REG_MODE3, | ||
| 301 | (max8952_read_reg(max8952, | ||
| 302 | MAX8952_REG_MODE3) & 0xC0) | | ||
| 303 | (pdata->dvs_mode[3] & 0x3F)); | ||
| 304 | |||
| 305 | max8952_write_reg(max8952, MAX8952_REG_SYNC, | ||
| 306 | (max8952_read_reg(max8952, MAX8952_REG_SYNC) & 0x3F) | | ||
| 307 | ((pdata->sync_freq & 0x3) << 6)); | ||
| 308 | max8952_write_reg(max8952, MAX8952_REG_RAMP, | ||
| 309 | (max8952_read_reg(max8952, MAX8952_REG_RAMP) & 0x1F) | | ||
| 310 | ((pdata->ramp_speed & 0x7) << 5)); | ||
| 311 | |||
| 312 | i2c_set_clientdata(client, max8952); | ||
| 313 | |||
| 314 | return 0; | ||
| 315 | |||
| 316 | err_reg: | ||
| 317 | kfree(max8952); | ||
| 318 | return ret; | ||
| 319 | } | ||
| 320 | |||
| 321 | static int __devexit max8952_pmic_remove(struct i2c_client *client) | ||
| 322 | { | ||
| 323 | struct max8952_data *max8952 = i2c_get_clientdata(client); | ||
| 324 | struct max8952_platform_data *pdata = max8952->pdata; | ||
| 325 | struct regulator_dev *rdev = max8952->rdev; | ||
| 326 | |||
| 327 | regulator_unregister(rdev); | ||
| 328 | |||
| 329 | gpio_free(pdata->gpio_vid0); | ||
| 330 | gpio_free(pdata->gpio_vid1); | ||
| 331 | gpio_free(pdata->gpio_en); | ||
| 332 | |||
| 333 | kfree(max8952); | ||
| 334 | return 0; | ||
| 335 | } | ||
| 336 | |||
| 337 | static const struct i2c_device_id max8952_ids[] = { | ||
| 338 | { "max8952", 0 }, | ||
| 339 | { }, | ||
| 340 | }; | ||
| 341 | MODULE_DEVICE_TABLE(i2c, max8952_ids); | ||
| 342 | |||
| 343 | static struct i2c_driver max8952_pmic_driver = { | ||
| 344 | .probe = max8952_pmic_probe, | ||
| 345 | .remove = __devexit_p(max8952_pmic_remove), | ||
| 346 | .driver = { | ||
| 347 | .name = "max8952", | ||
| 348 | }, | ||
| 349 | .id_table = max8952_ids, | ||
| 350 | }; | ||
| 351 | |||
| 352 | static int __init max8952_pmic_init(void) | ||
| 353 | { | ||
| 354 | return i2c_add_driver(&max8952_pmic_driver); | ||
| 355 | } | ||
| 356 | subsys_initcall(max8952_pmic_init); | ||
| 357 | |||
| 358 | static void __exit max8952_pmic_exit(void) | ||
| 359 | { | ||
| 360 | i2c_del_driver(&max8952_pmic_driver); | ||
| 361 | } | ||
| 362 | module_exit(max8952_pmic_exit); | ||
| 363 | |||
| 364 | MODULE_DESCRIPTION("MAXIM 8952 voltage regulator driver"); | ||
| 365 | MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>"); | ||
| 366 | MODULE_LICENSE("GPL"); | ||
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 2d6c6c8c036d..191616470466 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
| @@ -2718,7 +2718,7 @@ static int ext4_writepage(struct page *page, | |||
| 2718 | * try to create them using __block_write_begin. If this | 2718 | * try to create them using __block_write_begin. If this |
| 2719 | * fails, redirty the page and move on. | 2719 | * fails, redirty the page and move on. |
| 2720 | */ | 2720 | */ |
| 2721 | if (!page_buffers(page)) { | 2721 | if (!page_has_buffers(page)) { |
| 2722 | if (__block_write_begin(page, 0, len, | 2722 | if (__block_write_begin(page, 0, len, |
| 2723 | noalloc_get_block_write)) { | 2723 | noalloc_get_block_write)) { |
| 2724 | redirty_page: | 2724 | redirty_page: |
| @@ -2732,12 +2732,10 @@ static int ext4_writepage(struct page *page, | |||
| 2732 | if (walk_page_buffers(NULL, page_bufs, 0, len, NULL, | 2732 | if (walk_page_buffers(NULL, page_bufs, 0, len, NULL, |
| 2733 | ext4_bh_delay_or_unwritten)) { | 2733 | ext4_bh_delay_or_unwritten)) { |
| 2734 | /* | 2734 | /* |
| 2735 | * We don't want to do block allocation So redirty the | 2735 | * We don't want to do block allocation, so redirty |
| 2736 | * page and return We may reach here when we do a | 2736 | * the page and return. We may reach here when we do |
| 2737 | * journal commit via | 2737 | * a journal commit via journal_submit_inode_data_buffers. |
| 2738 | * journal_submit_inode_data_buffers. If we don't | 2738 | * We can also reach here via shrink_page_list |
| 2739 | * have mapping block we just ignore them. We can also | ||
| 2740 | * reach here via shrink_page_list | ||
| 2741 | */ | 2739 | */ |
| 2742 | goto redirty_page; | 2740 | goto redirty_page; |
| 2743 | } | 2741 | } |
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 064a80961677..84d3c8b90206 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
| @@ -873,7 +873,7 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, const struct iovec *iov, | |||
| 873 | dreq->inode = inode; | 873 | dreq->inode = inode; |
| 874 | dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp)); | 874 | dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp)); |
| 875 | dreq->l_ctx = nfs_get_lock_context(dreq->ctx); | 875 | dreq->l_ctx = nfs_get_lock_context(dreq->ctx); |
| 876 | if (dreq->l_ctx != NULL) | 876 | if (dreq->l_ctx == NULL) |
| 877 | goto out_release; | 877 | goto out_release; |
| 878 | if (!is_sync_kiocb(iocb)) | 878 | if (!is_sync_kiocb(iocb)) |
| 879 | dreq->iocb = iocb; | 879 | dreq->iocb = iocb; |
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c index dec47ed8b6b9..4e2d9b6b1380 100644 --- a/fs/nfs/idmap.c +++ b/fs/nfs/idmap.c | |||
| @@ -123,7 +123,7 @@ static ssize_t nfs_idmap_get_desc(const char *name, size_t namelen, | |||
| 123 | size_t desclen = typelen + namelen + 2; | 123 | size_t desclen = typelen + namelen + 2; |
| 124 | 124 | ||
| 125 | *desc = kmalloc(desclen, GFP_KERNEL); | 125 | *desc = kmalloc(desclen, GFP_KERNEL); |
| 126 | if (!desc) | 126 | if (!*desc) |
| 127 | return -ENOMEM; | 127 | return -ENOMEM; |
| 128 | 128 | ||
| 129 | cp = *desc; | 129 | cp = *desc; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 32c8758c99fd..0f24cdf2cb13 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
| @@ -429,7 +429,7 @@ static int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res * | |||
| 429 | * returned NFS4ERR_DELAY as per Section 2.10.6.2 | 429 | * returned NFS4ERR_DELAY as per Section 2.10.6.2 |
| 430 | * of RFC5661. | 430 | * of RFC5661. |
| 431 | */ | 431 | */ |
| 432 | dprintk("%s: slot=%ld seq=%d: Operation in progress\n", | 432 | dprintk("%s: slot=%td seq=%d: Operation in progress\n", |
| 433 | __func__, | 433 | __func__, |
| 434 | res->sr_slot - res->sr_session->fc_slot_table.slots, | 434 | res->sr_slot - res->sr_session->fc_slot_table.slots, |
| 435 | res->sr_slot->seq_nr); | 435 | res->sr_slot->seq_nr); |
| @@ -573,7 +573,7 @@ int nfs4_setup_sequence(const struct nfs_server *server, | |||
| 573 | goto out; | 573 | goto out; |
| 574 | } | 574 | } |
| 575 | 575 | ||
| 576 | dprintk("--> %s clp %p session %p sr_slot %ld\n", | 576 | dprintk("--> %s clp %p session %p sr_slot %td\n", |
| 577 | __func__, session->clp, session, res->sr_slot ? | 577 | __func__, session->clp, session, res->sr_slot ? |
| 578 | res->sr_slot - session->fc_slot_table.slots : -1); | 578 | res->sr_slot - session->fc_slot_table.slots : -1); |
| 579 | 579 | ||
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 919490232e17..137b549e63db 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
| @@ -65,6 +65,13 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode, | |||
| 65 | if (req == NULL) | 65 | if (req == NULL) |
| 66 | return ERR_PTR(-ENOMEM); | 66 | return ERR_PTR(-ENOMEM); |
| 67 | 67 | ||
| 68 | /* get lock context early so we can deal with alloc failures */ | ||
| 69 | req->wb_lock_context = nfs_get_lock_context(ctx); | ||
| 70 | if (req->wb_lock_context == NULL) { | ||
| 71 | nfs_page_free(req); | ||
| 72 | return ERR_PTR(-ENOMEM); | ||
| 73 | } | ||
| 74 | |||
| 68 | /* Initialize the request struct. Initially, we assume a | 75 | /* Initialize the request struct. Initially, we assume a |
| 69 | * long write-back delay. This will be adjusted in | 76 | * long write-back delay. This will be adjusted in |
| 70 | * update_nfs_request below if the region is not locked. */ | 77 | * update_nfs_request below if the region is not locked. */ |
| @@ -79,7 +86,6 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode, | |||
| 79 | req->wb_pgbase = offset; | 86 | req->wb_pgbase = offset; |
| 80 | req->wb_bytes = count; | 87 | req->wb_bytes = count; |
| 81 | req->wb_context = get_nfs_open_context(ctx); | 88 | req->wb_context = get_nfs_open_context(ctx); |
| 82 | req->wb_lock_context = nfs_get_lock_context(ctx); | ||
| 83 | kref_init(&req->wb_kref); | 89 | kref_init(&req->wb_kref); |
| 84 | return req; | 90 | return req; |
| 85 | } | 91 | } |
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 2c0fc10956ba..bd69d79208de 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
| @@ -640,7 +640,8 @@ | |||
| 640 | . = ALIGN(4); \ | 640 | . = ALIGN(4); \ |
| 641 | VMLINUX_SYMBOL(__initramfs_start) = .; \ | 641 | VMLINUX_SYMBOL(__initramfs_start) = .; \ |
| 642 | *(.init.ramfs) \ | 642 | *(.init.ramfs) \ |
| 643 | VMLINUX_SYMBOL(__initramfs_end) = .; | 643 | . = ALIGN(8); \ |
| 644 | *(.init.ramfs.info) | ||
| 644 | #else | 645 | #else |
| 645 | #define INIT_RAM_FS | 646 | #define INIT_RAM_FS |
| 646 | #endif | 647 | #endif |
diff --git a/include/linux/regulator/lp3972.h b/include/linux/regulator/lp3972.h new file mode 100644 index 000000000000..9bb7389b7a1e --- /dev/null +++ b/include/linux/regulator/lp3972.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* | ||
| 2 | * National Semiconductors LP3972 PMIC chip client interface | ||
| 3 | * | ||
| 4 | * Based on lp3971.h | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef __LINUX_REGULATOR_LP3972_H | ||
| 22 | #define __LINUX_REGULATOR_LP3972_H | ||
| 23 | |||
| 24 | #include <linux/regulator/machine.h> | ||
| 25 | |||
| 26 | #define LP3972_LDO1 0 | ||
| 27 | #define LP3972_LDO2 1 | ||
| 28 | #define LP3972_LDO3 2 | ||
| 29 | #define LP3972_LDO4 3 | ||
| 30 | #define LP3972_LDO5 4 | ||
| 31 | |||
| 32 | #define LP3972_DCDC1 5 | ||
| 33 | #define LP3972_DCDC2 6 | ||
| 34 | #define LP3972_DCDC3 7 | ||
| 35 | |||
| 36 | #define LP3972_NUM_REGULATORS 8 | ||
| 37 | |||
| 38 | struct lp3972_regulator_subdev { | ||
| 39 | int id; | ||
| 40 | struct regulator_init_data *initdata; | ||
| 41 | }; | ||
| 42 | |||
| 43 | struct lp3972_platform_data { | ||
| 44 | int num_regulators; | ||
| 45 | struct lp3972_regulator_subdev *regulators; | ||
| 46 | }; | ||
| 47 | |||
| 48 | #endif | ||
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index e2980287245e..761c745b9c24 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h | |||
| @@ -189,10 +189,15 @@ int regulator_suspend_prepare(suspend_state_t state); | |||
| 189 | 189 | ||
| 190 | #ifdef CONFIG_REGULATOR | 190 | #ifdef CONFIG_REGULATOR |
| 191 | void regulator_has_full_constraints(void); | 191 | void regulator_has_full_constraints(void); |
| 192 | void regulator_use_dummy_regulator(void); | ||
| 192 | #else | 193 | #else |
| 193 | static inline void regulator_has_full_constraints(void) | 194 | static inline void regulator_has_full_constraints(void) |
| 194 | { | 195 | { |
| 195 | } | 196 | } |
| 197 | |||
| 198 | static inline void regulator_use_dummy_regulator(void) | ||
| 199 | { | ||
| 200 | } | ||
| 196 | #endif | 201 | #endif |
| 197 | 202 | ||
| 198 | #endif | 203 | #endif |
diff --git a/include/linux/regulator/max8952.h b/include/linux/regulator/max8952.h new file mode 100644 index 000000000000..45e42855ad05 --- /dev/null +++ b/include/linux/regulator/max8952.h | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | /* | ||
| 2 | * max8952.h - Voltage regulation for the Maxim 8952 | ||
| 3 | * | ||
| 4 | * Copyright (C) 2010 Samsung Electrnoics | ||
| 5 | * MyungJoo Ham <myungjoo.ham@samsung.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #ifndef REGULATOR_MAX8952 | ||
| 23 | #define REGULATOR_MAX8952 | ||
| 24 | |||
| 25 | #include <linux/regulator/machine.h> | ||
| 26 | |||
| 27 | enum { | ||
| 28 | MAX8952_DVS_MODE0, | ||
| 29 | MAX8952_DVS_MODE1, | ||
| 30 | MAX8952_DVS_MODE2, | ||
| 31 | MAX8952_DVS_MODE3, | ||
| 32 | }; | ||
| 33 | |||
| 34 | enum { | ||
| 35 | MAX8952_DVS_770mV = 0, | ||
| 36 | MAX8952_DVS_780mV, | ||
| 37 | MAX8952_DVS_790mV, | ||
| 38 | MAX8952_DVS_800mV, | ||
| 39 | MAX8952_DVS_810mV, | ||
| 40 | MAX8952_DVS_820mV, | ||
| 41 | MAX8952_DVS_830mV, | ||
| 42 | MAX8952_DVS_840mV, | ||
| 43 | MAX8952_DVS_850mV, | ||
| 44 | MAX8952_DVS_860mV, | ||
| 45 | MAX8952_DVS_870mV, | ||
| 46 | MAX8952_DVS_880mV, | ||
| 47 | MAX8952_DVS_890mV, | ||
| 48 | MAX8952_DVS_900mV, | ||
| 49 | MAX8952_DVS_910mV, | ||
| 50 | MAX8952_DVS_920mV, | ||
| 51 | MAX8952_DVS_930mV, | ||
| 52 | MAX8952_DVS_940mV, | ||
| 53 | MAX8952_DVS_950mV, | ||
| 54 | MAX8952_DVS_960mV, | ||
| 55 | MAX8952_DVS_970mV, | ||
| 56 | MAX8952_DVS_980mV, | ||
| 57 | MAX8952_DVS_990mV, | ||
| 58 | MAX8952_DVS_1000mV, | ||
| 59 | MAX8952_DVS_1010mV, | ||
| 60 | MAX8952_DVS_1020mV, | ||
| 61 | MAX8952_DVS_1030mV, | ||
| 62 | MAX8952_DVS_1040mV, | ||
| 63 | MAX8952_DVS_1050mV, | ||
| 64 | MAX8952_DVS_1060mV, | ||
| 65 | MAX8952_DVS_1070mV, | ||
| 66 | MAX8952_DVS_1080mV, | ||
| 67 | MAX8952_DVS_1090mV, | ||
| 68 | MAX8952_DVS_1100mV, | ||
| 69 | MAX8952_DVS_1110mV, | ||
| 70 | MAX8952_DVS_1120mV, | ||
| 71 | MAX8952_DVS_1130mV, | ||
| 72 | MAX8952_DVS_1140mV, | ||
| 73 | MAX8952_DVS_1150mV, | ||
| 74 | MAX8952_DVS_1160mV, | ||
| 75 | MAX8952_DVS_1170mV, | ||
| 76 | MAX8952_DVS_1180mV, | ||
| 77 | MAX8952_DVS_1190mV, | ||
| 78 | MAX8952_DVS_1200mV, | ||
| 79 | MAX8952_DVS_1210mV, | ||
| 80 | MAX8952_DVS_1220mV, | ||
| 81 | MAX8952_DVS_1230mV, | ||
| 82 | MAX8952_DVS_1240mV, | ||
| 83 | MAX8952_DVS_1250mV, | ||
| 84 | MAX8952_DVS_1260mV, | ||
| 85 | MAX8952_DVS_1270mV, | ||
| 86 | MAX8952_DVS_1280mV, | ||
| 87 | MAX8952_DVS_1290mV, | ||
| 88 | MAX8952_DVS_1300mV, | ||
| 89 | MAX8952_DVS_1310mV, | ||
| 90 | MAX8952_DVS_1320mV, | ||
| 91 | MAX8952_DVS_1330mV, | ||
| 92 | MAX8952_DVS_1340mV, | ||
| 93 | MAX8952_DVS_1350mV, | ||
| 94 | MAX8952_DVS_1360mV, | ||
| 95 | MAX8952_DVS_1370mV, | ||
| 96 | MAX8952_DVS_1380mV, | ||
| 97 | MAX8952_DVS_1390mV, | ||
| 98 | MAX8952_DVS_1400mV, | ||
| 99 | }; | ||
| 100 | |||
| 101 | enum { | ||
| 102 | MAX8952_SYNC_FREQ_26MHZ, /* Default */ | ||
| 103 | MAX8952_SYNC_FREQ_13MHZ, | ||
| 104 | MAX8952_SYNC_FREQ_19_2MHZ, | ||
| 105 | }; | ||
| 106 | |||
| 107 | enum { | ||
| 108 | MAX8952_RAMP_32mV_us = 0, /* Default */ | ||
| 109 | MAX8952_RAMP_16mV_us, | ||
| 110 | MAX8952_RAMP_8mV_us, | ||
| 111 | MAX8952_RAMP_4mV_us, | ||
| 112 | MAX8952_RAMP_2mV_us, | ||
| 113 | MAX8952_RAMP_1mV_us, | ||
| 114 | MAX8952_RAMP_0_5mV_us, | ||
| 115 | MAX8952_RAMP_0_25mV_us, | ||
| 116 | }; | ||
| 117 | |||
| 118 | #define MAX8952_NUM_DVS_MODE 4 | ||
| 119 | |||
| 120 | struct max8952_platform_data { | ||
| 121 | int gpio_vid0; | ||
| 122 | int gpio_vid1; | ||
| 123 | int gpio_en; | ||
| 124 | |||
| 125 | u8 default_mode; | ||
| 126 | u8 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */ | ||
| 127 | |||
| 128 | u8 sync_freq; | ||
| 129 | u8 ramp_speed; | ||
| 130 | |||
| 131 | struct regulator_init_data reg_data; | ||
| 132 | }; | ||
| 133 | |||
| 134 | |||
| 135 | #endif /* REGULATOR_MAX8952 */ | ||
diff --git a/init/initramfs.c b/init/initramfs.c index d9c6e782ff53..2531811d42cb 100644 --- a/init/initramfs.c +++ b/init/initramfs.c | |||
| @@ -483,7 +483,8 @@ static int __init retain_initrd_param(char *str) | |||
| 483 | } | 483 | } |
| 484 | __setup("retain_initrd", retain_initrd_param); | 484 | __setup("retain_initrd", retain_initrd_param); |
| 485 | 485 | ||
| 486 | extern char __initramfs_start[], __initramfs_end[]; | 486 | extern char __initramfs_start[]; |
| 487 | extern unsigned long __initramfs_size; | ||
| 487 | #include <linux/initrd.h> | 488 | #include <linux/initrd.h> |
| 488 | #include <linux/kexec.h> | 489 | #include <linux/kexec.h> |
| 489 | 490 | ||
| @@ -570,8 +571,7 @@ static void __init clean_rootfs(void) | |||
| 570 | 571 | ||
| 571 | static int __init populate_rootfs(void) | 572 | static int __init populate_rootfs(void) |
| 572 | { | 573 | { |
| 573 | char *err = unpack_to_rootfs(__initramfs_start, | 574 | char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size); |
| 574 | __initramfs_end - __initramfs_start); | ||
| 575 | if (err) | 575 | if (err) |
| 576 | panic(err); /* Failed to decompress INTERNAL initramfs */ | 576 | panic(err); /* Failed to decompress INTERNAL initramfs */ |
| 577 | if (initrd_start) { | 577 | if (initrd_start) { |
| @@ -585,8 +585,7 @@ static int __init populate_rootfs(void) | |||
| 585 | return 0; | 585 | return 0; |
| 586 | } else { | 586 | } else { |
| 587 | clean_rootfs(); | 587 | clean_rootfs(); |
| 588 | unpack_to_rootfs(__initramfs_start, | 588 | unpack_to_rootfs(__initramfs_start, __initramfs_size); |
| 589 | __initramfs_end - __initramfs_start); | ||
| 590 | } | 589 | } |
| 591 | printk(KERN_INFO "rootfs image is not initramfs (%s)" | 590 | printk(KERN_INFO "rootfs image is not initramfs (%s)" |
| 592 | "; looks like an initrd\n", err); | 591 | "; looks like an initrd\n", err); |
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 6f89fbb56256..686cb0d31c7c 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean | |||
| @@ -45,6 +45,8 @@ __clean-files := $(extra-y) $(always) \ | |||
| 45 | $(host-progs) \ | 45 | $(host-progs) \ |
| 46 | $(hostprogs-y) $(hostprogs-m) $(hostprogs-) | 46 | $(hostprogs-y) $(hostprogs-m) $(hostprogs-) |
| 47 | 47 | ||
| 48 | __clean-files := $(filter-out $(no-clean-files), $(__clean-files)) | ||
| 49 | |||
| 48 | # as clean-files is given relative to the current directory, this adds | 50 | # as clean-files is given relative to the current directory, this adds |
| 49 | # a $(obj) prefix, except for absolute paths | 51 | # a $(obj) prefix, except for absolute paths |
| 50 | 52 | ||
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 7bfcf1a09ac5..4c72c1189479 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
| @@ -120,7 +120,9 @@ _c_flags += $(if $(patsubst n%,, \ | |||
| 120 | endif | 120 | endif |
| 121 | 121 | ||
| 122 | ifdef CONFIG_SYMBOL_PREFIX | 122 | ifdef CONFIG_SYMBOL_PREFIX |
| 123 | _cpp_flags += -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) | 123 | _sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) |
| 124 | _cpp_flags += $(_sym_flags) | ||
| 125 | _a_flags += $(_sym_flags) | ||
| 124 | endif | 126 | endif |
| 125 | 127 | ||
| 126 | 128 | ||
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index e3902fb39afd..60dd3eb9366e 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c | |||
| @@ -107,12 +107,8 @@ static int read_symbol(FILE *in, struct sym_entry *s) | |||
| 107 | 107 | ||
| 108 | rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str); | 108 | rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str); |
| 109 | if (rc != 3) { | 109 | if (rc != 3) { |
| 110 | if (rc != EOF) { | 110 | if (rc != EOF && fgets(str, 500, in) == NULL) |
| 111 | /* skip line. sym is used as dummy to | 111 | fprintf(stderr, "Read error or end of file.\n"); |
| 112 | * shut of "warn_unused_result" warning. | ||
| 113 | */ | ||
| 114 | sym = fgets(str, 500, in); | ||
| 115 | } | ||
| 116 | return -1; | 112 | return -1; |
| 117 | } | 113 | } |
| 118 | 114 | ||
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 1ec7158b6c1f..33122ca04e7c 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
| @@ -1208,6 +1208,9 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, | |||
| 1208 | * .cpuinit.data => __cpudata | 1208 | * .cpuinit.data => __cpudata |
| 1209 | * .memexitconst => __memconst | 1209 | * .memexitconst => __memconst |
| 1210 | * etc. | 1210 | * etc. |
| 1211 | * | ||
| 1212 | * The memory of returned value has been allocated on a heap. The user of this | ||
| 1213 | * method should free it after usage. | ||
| 1211 | */ | 1214 | */ |
| 1212 | static char *sec2annotation(const char *s) | 1215 | static char *sec2annotation(const char *s) |
| 1213 | { | 1216 | { |
| @@ -1230,7 +1233,7 @@ static char *sec2annotation(const char *s) | |||
| 1230 | strcat(p, "data "); | 1233 | strcat(p, "data "); |
| 1231 | else | 1234 | else |
| 1232 | strcat(p, " "); | 1235 | strcat(p, " "); |
| 1233 | return r; /* we leak her but we do not care */ | 1236 | return r; |
| 1234 | } else { | 1237 | } else { |
| 1235 | return strdup(""); | 1238 | return strdup(""); |
| 1236 | } | 1239 | } |
diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 057b6b3c5dfb..ef8729f48586 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion | |||
| @@ -160,8 +160,10 @@ if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then | |||
| 160 | # full scm version string | 160 | # full scm version string |
| 161 | res="$res$(scm_version)" | 161 | res="$res$(scm_version)" |
| 162 | else | 162 | else |
| 163 | # apped a plus sign if the repository is not in a clean tagged | 163 | # append a plus sign if the repository is not in a clean |
| 164 | # state and LOCALVERSION= is not specified | 164 | # annotated or signed tagged state (as git describe only |
| 165 | # looks at signed or annotated tags - git tag -a/-s) and | ||
| 166 | # LOCALVERSION= is not specified | ||
| 165 | if test "${LOCALVERSION+set}" != "set"; then | 167 | if test "${LOCALVERSION+set}" != "set"; then |
| 166 | scm=$(scm_version --short) | 168 | scm=$(scm_version --short) |
| 167 | res="$res${scm:++}" | 169 | res="$res${scm:++}" |
diff --git a/usr/Makefile b/usr/Makefile index 6b4b6da0b67d..6faa444b7087 100644 --- a/usr/Makefile +++ b/usr/Makefile | |||
| @@ -18,13 +18,15 @@ suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma | |||
| 18 | # Lzo | 18 | # Lzo |
| 19 | suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO) = .lzo | 19 | suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO) = .lzo |
| 20 | 20 | ||
| 21 | AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)" | ||
| 22 | |||
| 21 | # Generate builtin.o based on initramfs_data.o | 23 | # Generate builtin.o based on initramfs_data.o |
| 22 | obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data$(suffix_y).o | 24 | obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o |
| 23 | 25 | ||
| 24 | # initramfs_data.o contains the compressed initramfs_data.cpio image. | 26 | # initramfs_data.o contains the compressed initramfs_data.cpio image. |
| 25 | # The image is included using .incbin, a dependency which is not | 27 | # The image is included using .incbin, a dependency which is not |
| 26 | # tracked automatically. | 28 | # tracked automatically. |
| 27 | $(obj)/initramfs_data$(suffix_y).o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE | 29 | $(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE |
| 28 | 30 | ||
| 29 | ##### | 31 | ##### |
| 30 | # Generate the initramfs cpio archive | 32 | # Generate the initramfs cpio archive |
diff --git a/usr/initramfs_data.S b/usr/initramfs_data.S index 7c6973d8d829..b9efed5e35cc 100644 --- a/usr/initramfs_data.S +++ b/usr/initramfs_data.S | |||
| @@ -11,11 +11,7 @@ | |||
| 11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | 11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o |
| 12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | 12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o |
| 13 | 13 | ||
| 14 | initramfs_data.scr looks like this: | 14 | For including the .init.ramfs sections, see include/asm-generic/vmlinux.lds. |
| 15 | SECTIONS | ||
| 16 | { | ||
| 17 | .init.ramfs : { *(.data) } | ||
| 18 | } | ||
| 19 | 15 | ||
| 20 | The above example is for i386 - the parameters vary from architectures. | 16 | The above example is for i386 - the parameters vary from architectures. |
| 21 | Eventually look up LDFLAGS_BLOB in an older version of the | 17 | Eventually look up LDFLAGS_BLOB in an older version of the |
| @@ -25,6 +21,17 @@ SECTIONS | |||
| 25 | in the ELF header, as required by certain architectures. | 21 | in the ELF header, as required by certain architectures. |
| 26 | */ | 22 | */ |
| 27 | 23 | ||
| 28 | .section .init.ramfs,"a" | 24 | #include <linux/stringify.h> |
| 29 | .incbin "usr/initramfs_data.cpio" | ||
| 30 | 25 | ||
| 26 | .section .init.ramfs,"a" | ||
| 27 | __irf_start: | ||
| 28 | .incbin __stringify(INITRAMFS_IMAGE) | ||
| 29 | __irf_end: | ||
| 30 | .section .init.ramfs.info,"a" | ||
| 31 | .globl __initramfs_size | ||
| 32 | __initramfs_size: | ||
| 33 | #ifdef CONFIG_32BIT | ||
| 34 | .long __irf_end - __irf_start | ||
| 35 | #else | ||
| 36 | .quad __irf_end - __irf_start | ||
| 37 | #endif | ||
diff --git a/usr/initramfs_data.bz2.S b/usr/initramfs_data.bz2.S deleted file mode 100644 index bc54d090365c..000000000000 --- a/usr/initramfs_data.bz2.S +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | /* | ||
| 2 | initramfs_data includes the compressed binary that is the | ||
| 3 | filesystem used for early user space. | ||
| 4 | Note: Older versions of "as" (prior to binutils 2.11.90.0.23 | ||
| 5 | released on 2001-07-14) dit not support .incbin. | ||
| 6 | If you are forced to use older binutils than that then the | ||
| 7 | following trick can be applied to create the resulting binary: | ||
| 8 | |||
| 9 | |||
| 10 | ld -m elf_i386 --format binary --oformat elf32-i386 -r \ | ||
| 11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | ||
| 12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | ||
| 13 | |||
| 14 | initramfs_data.scr looks like this: | ||
| 15 | SECTIONS | ||
| 16 | { | ||
| 17 | .init.ramfs : { *(.data) } | ||
| 18 | } | ||
| 19 | |||
| 20 | The above example is for i386 - the parameters vary from architectures. | ||
| 21 | Eventually look up LDFLAGS_BLOB in an older version of the | ||
| 22 | arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. | ||
| 23 | |||
| 24 | Using .incbin has the advantage over ld that the correct flags are set | ||
| 25 | in the ELF header, as required by certain architectures. | ||
| 26 | */ | ||
| 27 | |||
| 28 | .section .init.ramfs,"a" | ||
| 29 | .incbin "usr/initramfs_data.cpio.bz2" | ||
diff --git a/usr/initramfs_data.gz.S b/usr/initramfs_data.gz.S deleted file mode 100644 index 890c8dd1d6bd..000000000000 --- a/usr/initramfs_data.gz.S +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | /* | ||
| 2 | initramfs_data includes the compressed binary that is the | ||
| 3 | filesystem used for early user space. | ||
| 4 | Note: Older versions of "as" (prior to binutils 2.11.90.0.23 | ||
| 5 | released on 2001-07-14) dit not support .incbin. | ||
| 6 | If you are forced to use older binutils than that then the | ||
| 7 | following trick can be applied to create the resulting binary: | ||
| 8 | |||
| 9 | |||
| 10 | ld -m elf_i386 --format binary --oformat elf32-i386 -r \ | ||
| 11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | ||
| 12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | ||
| 13 | |||
| 14 | initramfs_data.scr looks like this: | ||
| 15 | SECTIONS | ||
| 16 | { | ||
| 17 | .init.ramfs : { *(.data) } | ||
| 18 | } | ||
| 19 | |||
| 20 | The above example is for i386 - the parameters vary from architectures. | ||
| 21 | Eventually look up LDFLAGS_BLOB in an older version of the | ||
| 22 | arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. | ||
| 23 | |||
| 24 | Using .incbin has the advantage over ld that the correct flags are set | ||
| 25 | in the ELF header, as required by certain architectures. | ||
| 26 | */ | ||
| 27 | |||
| 28 | .section .init.ramfs,"a" | ||
| 29 | .incbin "usr/initramfs_data.cpio.gz" | ||
diff --git a/usr/initramfs_data.lzma.S b/usr/initramfs_data.lzma.S deleted file mode 100644 index e11469e48562..000000000000 --- a/usr/initramfs_data.lzma.S +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | /* | ||
| 2 | initramfs_data includes the compressed binary that is the | ||
| 3 | filesystem used for early user space. | ||
| 4 | Note: Older versions of "as" (prior to binutils 2.11.90.0.23 | ||
| 5 | released on 2001-07-14) dit not support .incbin. | ||
| 6 | If you are forced to use older binutils than that then the | ||
| 7 | following trick can be applied to create the resulting binary: | ||
| 8 | |||
| 9 | |||
| 10 | ld -m elf_i386 --format binary --oformat elf32-i386 -r \ | ||
| 11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | ||
| 12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | ||
| 13 | |||
| 14 | initramfs_data.scr looks like this: | ||
| 15 | SECTIONS | ||
| 16 | { | ||
| 17 | .init.ramfs : { *(.data) } | ||
| 18 | } | ||
| 19 | |||
| 20 | The above example is for i386 - the parameters vary from architectures. | ||
| 21 | Eventually look up LDFLAGS_BLOB in an older version of the | ||
| 22 | arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. | ||
| 23 | |||
| 24 | Using .incbin has the advantage over ld that the correct flags are set | ||
| 25 | in the ELF header, as required by certain architectures. | ||
| 26 | */ | ||
| 27 | |||
| 28 | .section .init.ramfs,"a" | ||
| 29 | .incbin "usr/initramfs_data.cpio.lzma" | ||
diff --git a/usr/initramfs_data.lzo.S b/usr/initramfs_data.lzo.S deleted file mode 100644 index 59211905da84..000000000000 --- a/usr/initramfs_data.lzo.S +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | /* | ||
| 2 | initramfs_data includes the compressed binary that is the | ||
| 3 | filesystem used for early user space. | ||
| 4 | Note: Older versions of "as" (prior to binutils 2.11.90.0.23 | ||
| 5 | released on 2001-07-14) dit not support .incbin. | ||
| 6 | If you are forced to use older binutils than that then the | ||
| 7 | following trick can be applied to create the resulting binary: | ||
| 8 | |||
| 9 | |||
| 10 | ld -m elf_i386 --format binary --oformat elf32-i386 -r \ | ||
| 11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | ||
| 12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | ||
| 13 | |||
| 14 | initramfs_data.scr looks like this: | ||
| 15 | SECTIONS | ||
| 16 | { | ||
| 17 | .init.ramfs : { *(.data) } | ||
| 18 | } | ||
| 19 | |||
| 20 | The above example is for i386 - the parameters vary from architectures. | ||
| 21 | Eventually look up LDFLAGS_BLOB in an older version of the | ||
| 22 | arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. | ||
| 23 | |||
| 24 | Using .incbin has the advantage over ld that the correct flags are set | ||
| 25 | in the ELF header, as required by certain architectures. | ||
| 26 | */ | ||
| 27 | |||
| 28 | .section .init.ramfs,"a" | ||
| 29 | .incbin "usr/initramfs_data.cpio.lzo" | ||
