changed Makefile and profiles, added patches for kernel 2.6.24
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1229-add-pcf50633-allow-force-charger-type.patch.patch
1 From f96aab45a604cb0f46a6ca3aa286a821c2462fda Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Sun, 13 Jul 2008 20:30:31 +0100
4 Subject: [PATCH] add-pcf50633-allow-force-charger-type.patch
5
6 This patch adds a sysfs node:
7
8 /sys/class/i2c-adapter/i2c-0/0-0073/force_usb_limit_dangerous
9
10 it allows to force the charging limit regardless of the one chosen
11 by pcf50633 kernel driver.  As such, if you write a charging limit
12 here that is not suitable for the power source, and the power source
13 is not current limited on its side, it could draw more current than
14 your power source can handle, burn down you house, etc.
15
16 If you're certain that your power supply can handle it, you can use
17 this on your own responsibility to make the amount drawn by the
18 PMU match what you believed your power supply could handle.
19
20 Example usage, in case where you have a dumb 500mA USB charger that
21 does not have the ID resistor:
22
23 # cat /sys/class/i2c-adapter/i2c-0/0-0073/charger_type
24 host/500mA usb mode 100mA   <=== dumb charger does not ennumerate us
25 # echo 500 > /sys/class/i2c-adapter/i2c-0/0-0073/force_usb_limit_dangerous
26 # cat /sys/class/i2c-adapter/i2c-0/0-0073/charger_type
27 host/500mA usb mode 500mA
28
29 Signed-off-by: Andy Green <andy@openmoko.com>
30 ---
31  drivers/i2c/chips/pcf50633.c |   15 +++++++++++++++
32  1 files changed, 15 insertions(+), 0 deletions(-)
33
34 diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
35 index a116f9f..9f98ba1 100644
36 --- a/drivers/i2c/chips/pcf50633.c
37 +++ b/drivers/i2c/chips/pcf50633.c
38 @@ -1953,6 +1953,20 @@ static ssize_t show_charger_type(struct device *dev,
39  
40  static DEVICE_ATTR(charger_type, 0444, show_charger_type, NULL);
41  
42 +static ssize_t force_usb_limit_dangerous(struct device *dev,
43 +                  struct device_attribute *attr, const char *buf, size_t count)
44 +{
45 +       struct i2c_client *client = to_i2c_client(dev);
46 +       struct pcf50633_data *pcf = i2c_get_clientdata(client);
47 +       int ma = simple_strtoul(buf, NULL, 10);
48 +
49 +       pcf50633_usb_curlim_set(pcf, ma);
50 +       return count;
51 +}
52 +
53 +static DEVICE_ATTR(force_usb_limit_dangerous, 0600,
54 +                                              NULL, force_usb_limit_dangerous);
55 +
56  /*
57   * Charger adc
58   */
59 @@ -2030,6 +2044,7 @@ static struct attribute *pcf_sysfs_entries[] = {
60         &dev_attr_voltage_ldo6.attr,
61         &dev_attr_voltage_hcldo.attr,
62         &dev_attr_charger_type.attr,
63 +       &dev_attr_force_usb_limit_dangerous.attr,
64         &dev_attr_charger_adc.attr,
65         &dev_attr_dump_regs.attr,
66         NULL, /* going to add things at this point! */
67 -- 
68 1.5.6.5
69