aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMattia Dongili <malattia@linux.it>2012-06-10 18:18:31 -0400
committerMatthew Garrett <mjg@redhat.com>2012-06-26 14:43:11 -0400
commit15aa5c75468a103cdee1a0e0ec26aad979bf71a5 (patch)
tree235696aa4f301a8ae6adf827a86357541927d8cc /drivers
parentbb384b5295323ed58260aeaff22d8bbe32988396 (diff)
sony-laptop: store battery care limits on batteries
Some models offer the option to store the limits on the battery (firmware?). Signed-off-by: Mattia Dongili <malattia@linux.it> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/platform/x86/sony-laptop.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 4f42e5661bf5..f045e3e59cd6 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1916,32 +1916,33 @@ static ssize_t sony_nc_battery_care_limit_store(struct device *dev,
1916 * bits 4,5: store the limit into the EC 1916 * bits 4,5: store the limit into the EC
1917 * bits 6,7: store the limit into the battery 1917 * bits 6,7: store the limit into the battery
1918 */ 1918 */
1919 cmd = 0;
1919 1920
1920 /* 1921 if (value > 0) {
1921 * handle 0x0115 should allow storing on battery too; 1922 if (value <= 50)
1922 * handle 0x0136 same as 0x0115 + health status; 1923 cmd = 0x20;
1923 * handle 0x013f, same as 0x0136 but no storing on the battery
1924 *
1925 * Store only inside the EC for now, regardless the handle number
1926 */
1927 if (value == 0)
1928 /* disable limits */
1929 cmd = 0x0;
1930 1924
1931 else if (value <= 50) 1925 else if (value <= 80)
1932 cmd = 0x21; 1926 cmd = 0x10;
1933 1927
1934 else if (value <= 80) 1928 else if (value <= 100)
1935 cmd = 0x11; 1929 cmd = 0x30;
1930
1931 else
1932 return -EINVAL;
1936 1933
1937 else if (value <= 100) 1934 /*
1938 cmd = 0x31; 1935 * handle 0x0115 should allow storing on battery too;
1936 * handle 0x0136 same as 0x0115 + health status;
1937 * handle 0x013f, same as 0x0136 but no storing on the battery
1938 */
1939 if (bcare_ctl->handle != 0x013f)
1940 cmd = cmd | (cmd << 2);
1939 1941
1940 else 1942 cmd = (cmd | 0x1) << 0x10;
1941 return -EINVAL; 1943 }
1942 1944
1943 if (sony_call_snc_handle(bcare_ctl->handle, (cmd << 0x10) | 0x0100, 1945 if (sony_call_snc_handle(bcare_ctl->handle, cmd | 0x0100, &result))
1944 &result))
1945 return -EIO; 1946 return -EIO;
1946 1947
1947 return count; 1948 return count;