Skip to contentSkip to conversation

New Nokia RX-51 power supply battery driver

PATCH Superseded Pali Rohár 6 participants 15 messages Oct 30, 2012 – Apr 10, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 New Nokia RX-51 power supply battery driver

Hello,

I'm sending new power_supply driver which export battery design capacity, battery temperature and voltage on Nokia N900. All these properties are read from battery pins throw twl madc channels.

I'm working on full BME replacement for Nokia N900. BME is Nokia proprietary buggy userspace software which charging battery. It has a lot of bugs and is blocker for USB host mode. Charging is done by bq24150a chip and some battery properties can be read from bq27200 chip. But battery design capacity and battery temperature must be read directly from battery (via twl madc channels). So this is reason for another power_supply driver on Nokia N900.

Except Nokia RX-51 Schematics there is no available documentation about battery, charging and madc channels (for n900), so all information was RE.

Big problem was converting RAW values from channels to standard which kernel report (uAh, uV, 1/100 C). There is no information about RAW unit. So conversation formula for capacity and voltage was taken from maemo binary bsi-read. Temperature formula was somehow computed.

But what is important is that proprietary SW BME can report current temperature (in K) and design capacity (in mAh) and also reporting corresponding RAW values. We tested this kernel driver and BME and both reported same battery capacity and temperature (+/- 1C). So data from this driver should be correct (if BME is correct).

Driver is only for Nokia N900. It is needed for open source project which will replace BME: https://gitorious.org/rx51-bme-replacement

Because twl4030_madc_conversion can be called only from kernel and there is battery interface in power supply it make sense me to write battery driver instead creating some method for exporting function twl4030_madc_conversion to user space (which is done on patched maemo kernel to allow BME calling twl4030_madc_conversion).

Thanks to Joerg Reisenweber and Ivaylo Dimitrov for collecting needed data, help with some problems and fixing errors!

drivers/power/rx51_battery.c new file +257 -0
@@ -0,0 +1,257 @@
+/*
+    rx51_battery.c - Nokia RX-51 battery driver
+    Copyright (C) 2012  Pali Rohár <[email protected]>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include <linux/module.h>
+#include <linux/param.h>
+#include <linux/platform_device.h>
+#include <linux/power_supply.h>
+#include <linux/slab.h>
+#include <linux/i2c/twl4030-madc.h>
+
+struct rx51_device_info {
+	struct device *dev;
+	struct power_supply bat;
+};
+
+/*
+   Read ADCIN channel value, code copied from maemo kernel
+ */
+static int rx51_battery_read_adc(int channel)
+{
+	struct twl4030_madc_request req;
+
+	req.channels = (1 << channel);
+	req.do_avg = 1;
+	req.method = TWL4030_MADC_SW1;
+	req.func_cb = NULL;
+	req.type = TWL4030_MADC_WAIT;
+
+	if (twl4030_madc_conversion(&req) > 0)
+		return req.rbuf[channel];
+	else
+		return -ENODATA;
+}
+
+/*
+   Read ADCIN channel 12 (voltage) and convert RAW value to micro voltage
+   This conversion formula was extracted from maemo program bsi-read
+ */
+static int rx51_battery_read_voltage(struct rx51_device_info *di)
+{
+	int voltage = rx51_battery_read_adc(12);
+	if (voltage < 0)
+		return voltage;
+	return 1000 * (10000 * voltage / 1705);
+}
+
+/*
+   Temperature look-up tables
+   TEMP = (1/(t1 + 1/298) - 273.15)
+   Where t1 = (1/B) * ln((RAW_ADC_U * 2.5)/(R * I * 255))
+   Formula is based on experimental data, RX-51 CAL data, maemo program bme
+   and formula from da9052 driver with values R = 100, B = 3380, I = 0.00671
+ */
+
+/*
+   Table1 (temperature for first 25 RAW values)
+   Usage: TEMP = rx51_temp_table1[RAW]
+     RAW is between 1 and 24
+     TEMP is between 201 C and 55 C
+ */
+static u8 rx51_temp_table1[] = {
+	255, 201, 159, 138, 124, 114, 106,  99,  94,  89,  85,  82,  78,  75,
+	 73,  70,  68,  66,  64,  62,  61,  59,  57,  56,  55
+};
+
+/*
+   Table2 (lowest RAW value for temperature)
+   Usage: RAW = rx51_temp_table2[TEMP-rx51_temp_table2_first]
+     TEMP is between 53 C and -32 C
+     RAW is between 25 and 993
+ */
+#define rx51_temp_table2_first 53
+static u16 rx51_temp_table2[] = {
+	 25,  26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  39,
+	 40,  41,  43,  44,  46,  48,  49,  51,  53,  55,  57,  59,  61,  64,
+	 66,  69,  71,  74,  77,  80,  83,  86,  90,  94,  97, 101, 106, 110,
+	115, 119, 125, 130, 136, 141, 148, 154, 161, 168, 176, 184, 202, 211,
+	221, 231, 242, 254, 266, 279, 293, 308, 323, 340, 357, 375, 395, 415,
+	437, 460, 485, 511, 539, 568, 600, 633, 669, 706, 747, 790, 836, 885,
+	937, 993, 1024
+};
+
+/*
+   Read ADCIN channel 0 (battery temp) and convert value to tenths of Celsius
+   Use Temperature look-up tables for conversation
+ */
+static int rx51_battery_read_temperature(struct rx51_device_info *di)
+{
+	int min = 0;
+	int max = ARRAY_SIZE(rx51_temp_table2)-1;
+	int raw = rx51_battery_read_adc(0);
+
+	/* Zero and negative values are undefined */
+	if (raw <= 0)
+		return INT_MAX;
+
+	/* ADC channels are 10 bit, higher value are undefined */
+	if (raw >= (1 << 10))
+		return INT_MIN;
+
+	/* First check for temperature in first direct table */
+	if (raw < ARRAY_SIZE(rx51_temp_table1))
+		return rx51_temp_table1[raw] * 100;
+
+	/* Binary search RAW value in second inverse table */
+	while (max-min > 1) {
+		int mid = (max+min)/2;
+		if (rx51_temp_table2[mid] <= raw)
+			min = mid;
+		else if (rx51_temp_table2[mid] > raw)
+			max = mid;
+		if (rx51_temp_table2[mid] == raw)
+			break;
+	}
+
+	return (rx51_temp_table2_first - min) * 100;
+}
+
+/*
+   Read ADCIN channel 4 (BSI) and convert RAW value to micro Ah
+   This conversion formula was extracted from maemo program bsi-read
+ */
+static int rx51_battery_read_capacity(struct rx51_device_info *di)
+{
+	int capacity = rx51_battery_read_adc(4);
+	if (capacity < 0)
+		return capacity;
+	return 1280 * (1200 * capacity)/(1024 - capacity);
+}
+
+/*
+   Return power_supply property
+ */
+static int rx51_battery_get_property(struct power_supply *psy,
+					enum power_supply_property psp,
+					union power_supply_propval *val)
+{
+	struct rx51_device_info *di = container_of((psy),
+				struct rx51_device_info, bat);
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_TECHNOLOGY:
+		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
+		val->intval = 4200000;
+		break;
+	case POWER_SUPPLY_PROP_PRESENT:
+		val->intval = rx51_battery_read_voltage(di) ? 1 : 0;
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+		val->intval = rx51_battery_read_voltage(di);
+		break;
+	case POWER_SUPPLY_PROP_TEMP:
+		val->intval = rx51_battery_read_temperature(di);
+		break;
+	case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
+		val->intval = rx51_battery_read_capacity(di);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (val->intval == INT_MAX || val->intval == INT_MIN)
+		return -EINVAL;
+
+	return 0;
+}
+
+static enum power_supply_property rx51_battery_props[] = {
+	POWER_SUPPLY_PROP_TECHNOLOGY,
+	POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
+	POWER_SUPPLY_PROP_PRESENT,
+	POWER_SUPPLY_PROP_VOLTAGE_NOW,
+	POWER_SUPPLY_PROP_TEMP,
+	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+};
+
+static int __devinit rx51_battery_probe(struct platform_device *pdev)
+{
+	struct rx51_device_info *di;
+	int ret;
+
+	di = kzalloc(sizeof(*di), GFP_KERNEL);
+	if (!di)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, di);
+
+	di->bat.name = dev_name(&pdev->dev);
+	di->bat.type = POWER_SUPPLY_TYPE_BATTERY;
+	di->bat.properties = rx51_battery_props;
+	di->bat.num_properties = ARRAY_SIZE(rx51_battery_props);
+	di->bat.get_property = rx51_battery_get_property;
+
+	ret = power_supply_register(di->dev, &di->bat);
+	if (ret) {
+		platform_set_drvdata(pdev, NULL);
+		kfree(di);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int __devexit rx51_battery_remove(struct platform_device *pdev)
+{
+	struct rx51_device_info *di = platform_get_drvdata(pdev);
+
+	power_supply_unregister(&di->bat);
+	platform_set_drvdata(pdev, NULL);
+	kfree(di);
+
+	return 0;
+}
+
+static struct platform_driver rx51_battery_driver = {
+	.probe = rx51_battery_probe,
+	.remove = __devexit_p(rx51_battery_remove),
+	.driver = {
+		.name = "rx51-battery",
+		.owner = THIS_MODULE,
+	},
+};
+
+static int __init rx51_battery_init(void)
+{
+	return platform_driver_register(&rx51_battery_driver);
+}
+module_init(rx51_battery_init);
+
+static void __exit rx51_battery_exit(void)
+{
+	platform_driver_unregister(&rx51_battery_driver);
+}
+module_exit(rx51_battery_exit);
+
+MODULE_ALIAS("platform:rx51-battery");
+MODULE_AUTHOR("Pali Rohár <[email protected]>");
+MODULE_DESCRIPTION("Nokia RX-51 battery driver");
+MODULE_LICENSE("GPL");
Signature · 2 lines
Pali Rohár
[email protected]
#1 lore raw
Quoted 2 lines · Pali Rohár

I'm working on full BME replacement for Nokia N900. BME is Nokia proprietary buggy userspace software which charging battery.

[...]

Quoted 3 lines

Except Nokia RX-51 Schematics there is no available documentation about battery, charging and madc channels (for n900), so all information was RE.

[...]

Quoted 2 lines

Thanks to Joerg Reisenweber and Ivaylo Dimitrov for collecting needed data, help with some problems and fixing errors!

Pali and guys, a huge thank you goes out to you, awesome work!

The driver looks great, just a few cosmetic issues.

(Please include a Signed-off-by tag on the next resend.)

Quoted 11 lines
drivers/power/rx51_battery.c new file +8 -0
@@ -0,0 +1,257 @@
+/*
+    rx51_battery.c - Nokia RX-51 battery driver
+    Copyright (C) 2012  Pali Rohár <[email protected]>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.

drivers/power/rx51_battery.c line 18

Quoted 10 lines
drivers/power/rx51_battery.c new file +10 -0
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/

The canonical multi-line comments are like this:

/*
* 1
* 2
*/

Quoted 6 lines
drivers/power/rx51_battery.c new file +6 -0
+
+#include <linux/module.h>
+#include <linux/param.h>
+#include <linux/platform_device.h>
+#include <linux/power_supply.h>
+#include <linux/slab.h>

drivers/power/rx51_battery.c line 34

Quoted 10 lines
drivers/power/rx51_battery.c new file +10 -0
+#include <linux/i2c/twl4030-madc.h>
+
+struct rx51_device_info {
+	struct device *dev;
+	struct power_supply bat;
+};
+
+/*
+   Read ADCIN channel value, code copied from maemo kernel
+ */

Ditto, style.

drivers/power/rx51_battery.c line 39

Quoted 5 lines
drivers/power/rx51_battery.c new file +5 -0
+static int rx51_battery_read_adc(int channel)
+{
+	struct twl4030_madc_request req;
+
+	req.channels = (1 << channel);

Parenthesis are not necessary here.

drivers/power/rx51_battery.c line 47

Quoted 8 lines
drivers/power/rx51_battery.c new file +8 -0
+	req.do_avg = 1;
+	req.method = TWL4030_MADC_SW1;
+	req.func_cb = NULL;
+	req.type = TWL4030_MADC_WAIT;
+
+	if (twl4030_madc_conversion(&req) > 0)
+		return req.rbuf[channel];
+	else

No need for 'else'.

Plus, to make it look more like a conventional error-handling, I'd write it as

	if (twl4030_madc_conversion(&req) <= 0)
		return -ENODATA;

	return req.rbuf[channel];

drivers/power/rx51_battery.c line 54

Quoted 7 lines
drivers/power/rx51_battery.c new file +7 -0
+		return -ENODATA;
+}
+
+/*
+   Read ADCIN channel 12 (voltage) and convert RAW value to micro voltage
+   This conversion formula was extracted from maemo program bsi-read
+ */

Style.

drivers/power/rx51_battery.c line 57

Quoted 3 lines
drivers/power/rx51_battery.c new file +3 -0
+static int rx51_battery_read_voltage(struct rx51_device_info *di)
+{
+	int voltage = rx51_battery_read_adc(12);

Need an empty line here.

Quoted 39 lines
drivers/power/rx51_battery.c new file +39 -0
+	if (voltage < 0)
+		return voltage;
+	return 1000 * (10000 * voltage / 1705);
+}
+
+/*
+   Temperature look-up tables
+   TEMP = (1/(t1 + 1/298) - 273.15)
+   Where t1 = (1/B) * ln((RAW_ADC_U * 2.5)/(R * I * 255))
+   Formula is based on experimental data, RX-51 CAL data, maemo program bme
+   and formula from da9052 driver with values R = 100, B = 3380, I = 0.00671
+ */
+
+/*
+   Table1 (temperature for first 25 RAW values)
+   Usage: TEMP = rx51_temp_table1[RAW]
+     RAW is between 1 and 24
+     TEMP is between 201 C and 55 C
+ */
+static u8 rx51_temp_table1[] = {
+	255, 201, 159, 138, 124, 114, 106,  99,  94,  89,  85,  82,  78,  75,
+	 73,  70,  68,  66,  64,  62,  61,  59,  57,  56,  55
+};
+
+/*
+   Table2 (lowest RAW value for temperature)
+   Usage: RAW = rx51_temp_table2[TEMP-rx51_temp_table2_first]
+     TEMP is between 53 C and -32 C
+     RAW is between 25 and 993
+ */
+#define rx51_temp_table2_first 53
+static u16 rx51_temp_table2[] = {
+	 25,  26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  39,
+	 40,  41,  43,  44,  46,  48,  49,  51,  53,  55,  57,  59,  61,  64,
+	 66,  69,  71,  74,  77,  80,  83,  86,  90,  94,  97, 101, 106, 110,
+	115, 119, 125, 130, 136, 141, 148, 154, 161, 168, 176, 184, 202, 211,
+	221, 231, 242, 254, 266, 279, 293, 308, 323, 340, 357, 375, 395, 415,
+	437, 460, 485, 511, 539, 568, 600, 633, 669, 706, 747, 790, 836, 885,
+	937, 993, 1024

drivers/power/rx51_battery.c line 106

Quoted 10 lines
drivers/power/rx51_battery.c new file +10 -0
+};
+
+/*
+   Read ADCIN channel 0 (battery temp) and convert value to tenths of Celsius
+   Use Temperature look-up tables for conversation
+ */
+static int rx51_battery_read_temperature(struct rx51_device_info *di)
+{
+	int min = 0;
+	int max = ARRAY_SIZE(rx51_temp_table2)-1;

Need spaces around '-'.

Quoted 6 lines
drivers/power/rx51_battery.c new file +6 -0
+	int raw = rx51_battery_read_adc(0);
+
+	/* Zero and negative values are undefined */
+	if (raw <= 0)
+		return INT_MAX;
+

drivers/power/rx51_battery.c line 122

Quoted 10 lines
drivers/power/rx51_battery.c new file +10 -0
+	/* ADC channels are 10 bit, higher value are undefined */
+	if (raw >= (1 << 10))
+		return INT_MIN;
+
+	/* First check for temperature in first direct table */
+	if (raw < ARRAY_SIZE(rx51_temp_table1))
+		return rx51_temp_table1[raw] * 100;
+
+	/* Binary search RAW value in second inverse table */
+	while (max-min > 1) {

Spaces around '-'.

drivers/power/rx51_battery.c line 123

Quoted 1 line
drivers/power/rx51_battery.c new file +1 -0
+		int mid = (max+min)/2;

Need an empty line here, spaces around '+' and '/'.

Quoted 8 lines
drivers/power/rx51_battery.c new file +8 -0
+		if (rx51_temp_table2[mid] <= raw)
+			min = mid;
+		else if (rx51_temp_table2[mid] > raw)
+			max = mid;
+		if (rx51_temp_table2[mid] == raw)
+			break;
+	}
+

drivers/power/rx51_battery.c line 141

Quoted 10 lines
drivers/power/rx51_battery.c new file +10 -0
+	return (rx51_temp_table2_first - min) * 100;
+}
+
+/*
+   Read ADCIN channel 4 (BSI) and convert RAW value to micro Ah
+   This conversion formula was extracted from maemo program bsi-read
+ */
+static int rx51_battery_read_capacity(struct rx51_device_info *di)
+{
+	int capacity = rx51_battery_read_adc(4);

Empty line here.

Quoted 101 lines
drivers/power/rx51_battery.c new file +101 -0
+	if (capacity < 0)
+		return capacity;
+	return 1280 * (1200 * capacity)/(1024 - capacity);
+}
+
+/*
+   Return power_supply property
+ */
+static int rx51_battery_get_property(struct power_supply *psy,
+					enum power_supply_property psp,
+					union power_supply_propval *val)
+{
+	struct rx51_device_info *di = container_of((psy),
+				struct rx51_device_info, bat);
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_TECHNOLOGY:
+		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
+		val->intval = 4200000;
+		break;
+	case POWER_SUPPLY_PROP_PRESENT:
+		val->intval = rx51_battery_read_voltage(di) ? 1 : 0;
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+		val->intval = rx51_battery_read_voltage(di);
+		break;
+	case POWER_SUPPLY_PROP_TEMP:
+		val->intval = rx51_battery_read_temperature(di);
+		break;
+	case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
+		val->intval = rx51_battery_read_capacity(di);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (val->intval == INT_MAX || val->intval == INT_MIN)
+		return -EINVAL;
+
+	return 0;
+}
+
+static enum power_supply_property rx51_battery_props[] = {
+	POWER_SUPPLY_PROP_TECHNOLOGY,
+	POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
+	POWER_SUPPLY_PROP_PRESENT,
+	POWER_SUPPLY_PROP_VOLTAGE_NOW,
+	POWER_SUPPLY_PROP_TEMP,
+	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+};
+
+static int __devinit rx51_battery_probe(struct platform_device *pdev)
+{
+	struct rx51_device_info *di;
+	int ret;
+
+	di = kzalloc(sizeof(*di), GFP_KERNEL);
+	if (!di)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, di);
+
+	di->bat.name = dev_name(&pdev->dev);
+	di->bat.type = POWER_SUPPLY_TYPE_BATTERY;
+	di->bat.properties = rx51_battery_props;
+	di->bat.num_properties = ARRAY_SIZE(rx51_battery_props);
+	di->bat.get_property = rx51_battery_get_property;
+
+	ret = power_supply_register(di->dev, &di->bat);
+	if (ret) {
+		platform_set_drvdata(pdev, NULL);
+		kfree(di);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int __devexit rx51_battery_remove(struct platform_device *pdev)
+{
+	struct rx51_device_info *di = platform_get_drvdata(pdev);
+
+	power_supply_unregister(&di->bat);
+	platform_set_drvdata(pdev, NULL);
+	kfree(di);
+
+	return 0;
+}
+
+static struct platform_driver rx51_battery_driver = {
+	.probe = rx51_battery_probe,
+	.remove = __devexit_p(rx51_battery_remove),
+	.driver = {
+		.name = "rx51-battery",
+		.owner = THIS_MODULE,
+	},
+};
+
+static int __init rx51_battery_init(void)

drivers/power/rx51_battery.c line 252

Quoted 10 lines
drivers/power/rx51_battery.c new file +10 -0
+{
+	return platform_driver_register(&rx51_battery_driver);
+}
+module_init(rx51_battery_init);
+
+static void __exit rx51_battery_exit(void)
+{
+	platform_driver_unregister(&rx51_battery_driver);
+}
+module_exit(rx51_battery_exit);

I guess these two calls can be replaced by module_platform_driver() macro.

drivers/power/rx51_battery.c line 257

Quoted 4 lines
drivers/power/rx51_battery.c new file +4 -0
+MODULE_ALIAS("platform:rx51-battery");
+MODULE_AUTHOR("Pali Rohár <[email protected]>");
+MODULE_DESCRIPTION("Nokia RX-51 battery driver");
+MODULE_LICENSE("GPL");

Otherwise, it looks very good!

Thanks,
Anton.

#2 lore raw

PATCH v2 1/1 New Nokia RX-51 power supply battery driver

Hello, I fixed style issues and added it to Makefile and Kconfig.

power_supply: Add Nokia RX-51 battery driver

This driver exporting battery design capacity, temperature and voltage for battery in Nokia RX-51. This driver is needed for open source battery management on Nokia RX-51 (N900).

drivers/power/rx51_battery.c new file +251 -0
@@ -0,0 +1,251 @@
+/*
+ *  rx51_battery.c - Nokia RX-51 battery driver
+ *  Copyright (C) 2012  Pali Rohár <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/module.h>
+#include <linux/param.h>
+#include <linux/platform_device.h>
+#include <linux/power_supply.h>
+#include <linux/slab.h>
+#include <linux/i2c/twl4030-madc.h>
+
+struct rx51_device_info {
+	struct device *dev;
+	struct power_supply bat;
+};
+
+/*
+ * Read ADCIN channel value, code copied from maemo kernel
+ */
+static int rx51_battery_read_adc(int channel)
+{
+	struct twl4030_madc_request req;
+
+	req.channels = 1 << channel;
+	req.do_avg = 1;
+	req.method = TWL4030_MADC_SW1;
+	req.func_cb = NULL;
+	req.type = TWL4030_MADC_WAIT;
+
+	if (twl4030_madc_conversion(&req) <= 0)
+		return -ENODATA;
+
+	return req.rbuf[channel];
+}
+
+/*
+ * Read ADCIN channel 12 (voltage) and convert RAW value to micro voltage
+ * This conversion formula was extracted from maemo program bsi-read
+ */
+static int rx51_battery_read_voltage(struct rx51_device_info *di)
+{
+	int voltage = rx51_battery_read_adc(12);
+
+	if (voltage < 0)
+		return voltage;
+
+	return 1000 * (10000 * voltage / 1705);
+}
+
+/*
+ * Temperature look-up tables
+ * TEMP = (1/(t1 + 1/298) - 273.15)
+ * Where t1 = (1/B) * ln((RAW_ADC_U * 2.5)/(R * I * 255))
+ * Formula is based on experimental data, RX-51 CAL data, maemo program bme
+ * and formula from da9052 driver with values R = 100, B = 3380, I = 0.00671
+ */
+
+/*
+ * Table1 (temperature for first 25 RAW values)
+ * Usage: TEMP = rx51_temp_table1[RAW]
+ *   RAW is between 1 and 24
+ *   TEMP is between 201 C and 55 C
+ */
+static u8 rx51_temp_table1[] = {
+	255, 201, 159, 138, 124, 114, 106,  99,  94,  89,  85,  82,  78,  75,
+	 73,  70,  68,  66,  64,  62,  61,  59,  57,  56,  55
+};
+
+/*
+ * Table2 (lowest RAW value for temperature)
+ * Usage: RAW = rx51_temp_table2[TEMP-rx51_temp_table2_first]
+ *   TEMP is between 53 C and -32 C
+ *   RAW is between 25 and 993
+ */
+#define rx51_temp_table2_first 53
+static u16 rx51_temp_table2[] = {
+	 25,  26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  39,
+	 40,  41,  43,  44,  46,  48,  49,  51,  53,  55,  57,  59,  61,  64,
+	 66,  69,  71,  74,  77,  80,  83,  86,  90,  94,  97, 101, 106, 110,
+	115, 119, 125, 130, 136, 141, 148, 154, 161, 168, 176, 184, 202, 211,
+	221, 231, 242, 254, 266, 279, 293, 308, 323, 340, 357, 375, 395, 415,
+	437, 460, 485, 511, 539, 568, 600, 633, 669, 706, 747, 790, 836, 885,
+	937, 993, 1024
+};
+
+/*
+ * Read ADCIN channel 0 (battery temp) and convert value to tenths of Celsius
+ * Use Temperature look-up tables for conversation
+ */
+static int rx51_battery_read_temperature(struct rx51_device_info *di)
+{
+	int min = 0;
+	int max = ARRAY_SIZE(rx51_temp_table2) - 1;
+	int raw = rx51_battery_read_adc(0);
+
+	/* Zero and negative values are undefined */
+	if (raw <= 0)
+		return INT_MAX;
+
+	/* ADC channels are 10 bit, higher value are undefined */
+	if (raw >= (1 << 10))
+		return INT_MIN;
+
+	/* First check for temperature in first direct table */
+	if (raw < ARRAY_SIZE(rx51_temp_table1))
+		return rx51_temp_table1[raw] * 100;
+
+	/* Binary search RAW value in second inverse table */
+	while (max - min > 1) {
+		int mid = (max + min) / 2;
+		if (rx51_temp_table2[mid] <= raw)
+			min = mid;
+		else if (rx51_temp_table2[mid] > raw)
+			max = mid;
+		if (rx51_temp_table2[mid] == raw)
+			break;
+	}
+
+	return (rx51_temp_table2_first - min) * 100;
+}
+
+/*
+ * Read ADCIN channel 4 (BSI) and convert RAW value to micro Ah
+ * This conversion formula was extracted from maemo program bsi-read
+ */
+static int rx51_battery_read_capacity(struct rx51_device_info *di)
+{
+	int capacity = rx51_battery_read_adc(4);
+
+	if (capacity < 0)
+		return capacity;
+
+	return 1280 * (1200 * capacity)/(1024 - capacity);
+}
+
+/*
+ * Return power_supply property
+ */
+static int rx51_battery_get_property(struct power_supply *psy,
+					enum power_supply_property psp,
+					union power_supply_propval *val)
+{
+	struct rx51_device_info *di = container_of((psy),
+				struct rx51_device_info, bat);
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_TECHNOLOGY:
+		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
+		val->intval = 4200000;
+		break;
+	case POWER_SUPPLY_PROP_PRESENT:
+		val->intval = rx51_battery_read_voltage(di) ? 1 : 0;
+		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+		val->intval = rx51_battery_read_voltage(di);
+		break;
+	case POWER_SUPPLY_PROP_TEMP:
+		val->intval = rx51_battery_read_temperature(di);
+		break;
+	case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
+		val->intval = rx51_battery_read_capacity(di);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	if (val->intval == INT_MAX || val->intval == INT_MIN)
+		return -EINVAL;
+
+	return 0;
+}
+
+static enum power_supply_property rx51_battery_props[] = {
+	POWER_SUPPLY_PROP_TECHNOLOGY,
+	POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
+	POWER_SUPPLY_PROP_PRESENT,
+	POWER_SUPPLY_PROP_VOLTAGE_NOW,
+	POWER_SUPPLY_PROP_TEMP,
+	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+};
+
+static int __devinit rx51_battery_probe(struct platform_device *pdev)
+{
+	struct rx51_device_info *di;
+	int ret;
+
+	di = kzalloc(sizeof(*di), GFP_KERNEL);
+	if (!di)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, di);
+
+	di->bat.name = dev_name(&pdev->dev);
+	di->bat.type = POWER_SUPPLY_TYPE_BATTERY;
+	di->bat.properties = rx51_battery_props;
+	di->bat.num_properties = ARRAY_SIZE(rx51_battery_props);
+	di->bat.get_property = rx51_battery_get_property;
+
+	ret = power_supply_register(di->dev, &di->bat);
+	if (ret) {
+		platform_set_drvdata(pdev, NULL);
+		kfree(di);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int __devexit rx51_battery_remove(struct platform_device *pdev)
+{
+	struct rx51_device_info *di = platform_get_drvdata(pdev);
+
+	power_supply_unregister(&di->bat);
+	platform_set_drvdata(pdev, NULL);
+	kfree(di);
+
+	return 0;
+}
+
+static struct platform_driver rx51_battery_driver = {
+	.probe = rx51_battery_probe,
+	.remove = __devexit_p(rx51_battery_remove),
+	.driver = {
+		.name = "rx51-battery",
+		.owner = THIS_MODULE,
+	},
+};
+
+module_platform_driver(rx51_battery_driver);
+
+MODULE_ALIAS("platform:rx51-battery");
+MODULE_AUTHOR("Pali Rohár <[email protected]>");
+MODULE_DESCRIPTION("Nokia RX-51 battery driver");
+MODULE_LICENSE("GPL");
drivers/power/Kconfig +6 -0
@@ -245,6 +245,12 @@ config BATTERY_INTEL_MID
 	  Say Y here to enable the battery driver on Intel MID
 	  platforms.
 
+config BATTERY_RX51
+	tristate "Nokia RX-51 battery driver"
+	depends on TWL4030_MADC
+	help
+	  Say Y here to enable support for battery information on Nokia RX-51.
+
 config CHARGER_ISP1704
 	tristate "ISP1704 USB Charger Detection"
 	depends on USB_OTG_UTILS
drivers/power/Makefile +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_CHARGER_88PM860X)	+= 88pm860x_charger.o
 obj-$(CONFIG_CHARGER_PCF50633)	+= pcf50633-charger.o
 obj-$(CONFIG_BATTERY_JZ4740)	+= jz4740-battery.o
 obj-$(CONFIG_BATTERY_INTEL_MID)	+= intel_mid_battery.o
+obj-$(CONFIG_BATTERY_RX51)	+= rx51_battery.o
 obj-$(CONFIG_AB8500_BM)		+= ab8500_charger.o ab8500_btemp.o ab8500_fg.o abx500_chargalg.o
 obj-$(CONFIG_CHARGER_ISP1704)	+= isp1704_charger.o
 obj-$(CONFIG_CHARGER_MAX8903)	+= max8903_charger.o
Signature · 2 lines
Pali Rohár
[email protected]
#3 lore raw
Quoted 9 lines · Pali Rohár

Hello, I fixed style issues and added it to Makefile and Kconfig.

power_supply: Add Nokia RX-51 battery driver

This driver exporting battery design capacity, temperature and voltage for battery in Nokia RX-51. This driver is needed for open source battery management on Nokia RX-51 (N900).

Looks great, thank you! This is now in the battery git tree.

p.s.

fwiw, I added the N900 reference to the user-visible Kconfig text:

config BATTERY_RX51
- tristate "Nokia RX-51 battery driver"
+ tristate "Nokia RX-51 (N900) battery driver"
depends on TWL4030_MADC
help

-	  Say Y here to enable support for battery information on Nokia RX-51.
+	  Say Y here to enable support for battery information on Nokia
+	  RX-51, also known as N900 tablet.
#4 lore raw
Quoted 26 lines · On Sunday 18 November 2012 15:12:40 Anton Vorontsov wrote:
Quoted 11 lines · Pali Rohár

Hello, I fixed style issues and added it to Makefile and Kconfig.

power_supply: Add Nokia RX-51 battery driver

This driver exporting battery design capacity, temperature and voltage for battery in Nokia RX-51. This driver is needed for open source battery management on Nokia RX-51 (N900).

Looks great, thank you! This is now in the battery git tree.

p.s.

fwiw, I added the N900 reference to the user-visible Kconfig text:

config BATTERY_RX51

(quoted diff) +1 -2
-	tristate "Nokia RX-51 battery driver"
+	tristate "Nokia RX-51 (N900) battery driver"
 	depends on TWL4030_MADC
 	help
-	  Say Y here to enable support for battery information on
Quoted 2 lines

Nokia RX-51. + Say Y here to enable support for battery
information on Nokia + RX-51, also known as N900 tablet.

Ok. Here is missing patch which register this driver in Nokia N900 board code. Without it driver is not loaded.

Quoted 1 line

From 0b60efd06a71668439bcb761c6572dd7df91dc17 Mon Sep 17 00:00:00 2001

From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Mon, 19 Nov 2012 09:05:24 +0100
Subject: [PATCH 1/3] ARM: OMAP: rx51: Register platform device for
rx51_battery driver
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 arch/arm/mach-omap2/board-rx51-peripherals.c |    6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-omap2/board-rx51-peripherals.c +6 -0
index 020e03c..fe1ac7e 100644
@@ -271,11 +271,17 @@ static struct platform_device rx51_charger_device = {
 	},
 };
 
+static struct platform_device rx51_battery_device = {
+	.name		= "rx51-battery",
+	.id		= -1,
+};
+
 static void __init rx51_charger_init(void)
 {
 	WARN_ON(gpio_request_one(RX51_USB_TRANSCEIVER_RST_GPIO,
 		GPIOF_OUT_INIT_HIGH, "isp1704_reset"));
 
+	platform_device_register(&rx51_battery_device);
 	platform_device_register(&rx51_charger_device);
 }
 
Signature · 5 lines
1.7.10.4

-- 
Pali Rohár
[email protected]
#5 lore raw

On Mon, Nov 19, 2012 at 01:18:29PM +0100, Pali Rohár wrote:
[...]

Quoted 1 line

Ok. Here is missing patch which register this driver in Nokia N900 board code. Without it driver is not loaded.

Cc'ing OMAP folks.

Quoted 42 lines

From 0b60efd06a71668439bcb761c6572dd7df91dc17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Mon, 19 Nov 2012 09:05:24 +0100
Subject: [PATCH 1/3] ARM: OMAP: rx51: Register platform device for
rx51_battery driver
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 arch/arm/mach-omap2/board-rx51-peripherals.c |    6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-omap2/board-rx51-peripherals.c +6 -0
index 020e03c..fe1ac7e 100644
@@ -271,11 +271,17 @@ static struct platform_device rx51_charger_device = {
 	},
 };
 
+static struct platform_device rx51_battery_device = {
+	.name		= "rx51-battery",
+	.id		= -1,
+};
+
 static void __init rx51_charger_init(void)
 {
 	WARN_ON(gpio_request_one(RX51_USB_TRANSCEIVER_RST_GPIO,
 		GPIOF_OUT_INIT_HIGH, "isp1704_reset"));
 
+	platform_device_register(&rx51_battery_device);
 	platform_device_register(&rx51_charger_device);
 }
 
Signature · 5 lines
1.7.10.4

-- 
Pali Rohár
[email protected]
maintainer Acked-by
#6 lore raw
Quoted 5 lines · Anton Vorontsov

On Mon, Nov 19, 2012 at 01:18:29PM +0100, Pali Rohár wrote:
[...]

Quoted 1 line

Ok. Here is missing patch which register this driver in Nokia N900 board code. Without it driver is not loaded.

Cc'ing OMAP folks.

Looks OK to me queue with the other patches in the series:

Quoted 42 lines

From 0b60efd06a71668439bcb761c6572dd7df91dc17 Mon Sep 17 00:00:00 2001

Quoted 41 lines

From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
Date: Mon, 19 Nov 2012 09:05:24 +0100
Subject: [PATCH 1/3] ARM: OMAP: rx51: Register platform device for
rx51_battery driver
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 arch/arm/mach-omap2/board-rx51-peripherals.c |    6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-omap2/board-rx51-peripherals.c +6 -0
index 020e03c..fe1ac7e 100644
@@ -271,11 +271,17 @@ static struct platform_device rx51_charger_device = {
 	},
 };
 
+static struct platform_device rx51_battery_device = {
+	.name		= "rx51-battery",
+	.id		= -1,
+};
+
 static void __init rx51_charger_init(void)
 {
 	WARN_ON(gpio_request_one(RX51_USB_TRANSCEIVER_RST_GPIO,
 		GPIOF_OUT_INIT_HIGH, "isp1704_reset"));
 
+	platform_device_register(&rx51_battery_device);
 	platform_device_register(&rx51_charger_device);
 }
 
Signature · 5 lines
1.7.10.4

-- 
Pali Rohár
[email protected]
#7 lore raw
Quoted 10 lines · Tony Lindgren
Quoted 5 lines · Anton Vorontsov

On Mon, Nov 19, 2012 at 01:18:29PM +0100, Pali Rohár wrote:
[...]

Quoted 1 line

Ok. Here is missing patch which register this driver in Nokia N900 board code. Without it driver is not loaded.

Cc'ing OMAP folks.

Looks OK to me queue with the other patches in the series:

Applied, thanks!

(I'll make a second pull request for this window, but no sure if it will make it. We will see.)

Thanks,
Anton

Reviewed-by on v2 1/1
#8 lore raw
In reply to Pali Rohár
Quoted 9 lines · Pali Rohár

Hello, I fixed style issues and added it to Makefile and Kconfig.

power_supply: Add Nokia RX-51 battery driver

This driver exporting battery design capacity, temperature and voltage for battery in Nokia RX-51. This driver is needed for open source battery management on Nokia RX-51 (N900).

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#9 lore raw
Quoted 5 lines · Pavel Machek
Quoted 4 lines · Pali Rohár

Hello, I fixed style issues and added it to Makefile and Kconfig.

power_supply: Add Nokia RX-51 battery driver

Quoted 7 lines
Quoted 5 lines

This driver exporting battery design capacity, temperature and voltage for battery in Nokia RX-51. This driver is needed for open source battery management on Nokia RX-51 (N900).

Thanks for the review, Pavel! Although, the patch is in Linus' tree long ago. ;-)

Anton

#10 lore raw
Quoted 10 lines · Anton Vorontsov
Quoted 9 lines · Pavel Machek
Quoted 8 lines · Pali Rohár

Hello, I fixed style issues and added it to Makefile and Kconfig.

power_supply: Add Nokia RX-51 battery driver

This driver exporting battery design capacity, temperature and voltage for battery in Nokia RX-51. This driver is needed for open source battery management on Nokia RX-51 (N900).

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Thanks for the review, Pavel! Although, the patch is in Linus' tree long ago. ;-)

Yeah... I did a bit of history-digging ;-). Now, I should figure out how to put custom kernel on n900 _and_ keep it in working state at the same time.

(I installed some kind of multiboot, then, apt decided to install some u-boot extension. Then it got interesting. I never got my own kernel to work, and u-boot magically disappeared, but I still have working phone :-).

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#11 lore raw
Quoted 24 lines · On Saturday 30 March 2013 22:42:29 Pavel Machek wrote:
Quoted 12 lines · Anton Vorontsov
Quoted 11 lines · Pavel Machek
Quoted 10 lines · Pali Rohár

Hello, I fixed style issues and added it to Makefile and Kconfig.

power_supply: Add Nokia RX-51 battery driver

This driver exporting battery design capacity, temperature and voltage for battery in Nokia RX-51. This driver is needed for open source battery management on Nokia RX-51 (N900).

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Thanks for the review, Pavel! Although, the patch is in Linus' tree long ago. ;-)

Yeah... I did a bit of history-digging ;-). Now, I should figure out how to put custom kernel on n900 _and_ keep it in working state at the same time.

Quoted 6 lines

(I installed some kind of multiboot, then, apt decided to install some u-boot extension. Then it got interesting. I never got my own kernel to work, and u-boot magically disappeared, but I still have working phone :-).

Pavel

Hello Pavel,

here are some hints for booting 3.8+ kernel on n900:

"multiboot" package from Maemo Extras is horrible hack which can be used only for booting maemo 2.6.28 kernel. it flashing new kernel to n900 nand, then reboot device, start maemo init and mount/chroot into new os dir... after reboot it erasing kernel nand area where is normaly uboot placed, so do not install it!

uboot in Maemo Extras cannot boot 3.x kernels because autobuilder (Extras server app for buidling packages) has very old gcc which produced semi-(non)working uboot (can boot some 2.6 kernels).

my uboot builds compiled by gcc 4.7 (which can boot 3.8 kernel):
http://atrey.karlin.mff.cuni.cz/~pali/u-boot/

info thread about uboot on n900:
http://talk.maemo.org/showthread.php?t=81613

kernel git repository with n900 patches (now based on v3.8-rc3):
https://gitorious.org/linux-n900/linux-n900

open source flasher 0xFFFF (working on x86-64 too) which can load kernel and initfs via usb to n900 RAM without flashing nand:
https://gitorious.org/0xffff/0xffff

rescueOS - minimalistic n900 initrams distribution with usb mass storage (eMMC and SD) and usb cdc ether for telnet console
http://206.253.166.96/N900/rescueOS/

If you need help with booting some upstream kernel on n900 join to freenode #maemo-alternatives channel :-)

Signature · 2 lines
Pali Rohár
[email protected]
#12 lore raw

HI!

Quoted 2 lines

kernel git repository with n900 patches (now based on v3.8-rc3):
https://gitorious.org/linux-n900/linux-n900

Ok, I am getting this with defconfig:

CC arch/arm/mach-omap2/board-rx51-peripherals.o
arch/arm/mach-omap2/board-rx51-peripherals.c:1040: error: unknown field ‘arb_mode’ specified in initializer arch/arm/mach-omap2/board-rx51-peripherals.c:1040: warning: missing braces around initializer arch/arm/mach-omap2/board-rx51-peripherals.c:1040: warning: (near initialization for ‘rx51_ssi_cl[1].tx_cfg.<anonymous>’) make[1]: *** [arch/arm/mach-omap2/board-rx51-peripherals.o] Error 1
make: *** [arch/arm/mach-omap2] Error 2

I hope I have right tree:

commit b6537e4a86afe74cc67dc3f96e145024e0638d0c

Author: Pali Rohár <[email protected]>
Date:   Sun Feb 17 22:37:21 2013 +0100

rx51_defconfig: Use smiapp driver instead smia-sensor driver for front webcam

Quoted 3 lines

open source flasher 0xFFFF (working on x86-64 too) which can load kernel and initfs via usb to n900 RAM without flashing nand:
https://gitorious.org/0xffff/0xffff

This compiles ok, lets see if it works.

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#13 lore raw
In reply to Pali Rohár

Hi!

Quoted 3 lines

open source flasher 0xFFFF (working on x86-64 too) which can load kernel and initfs via usb to n900 RAM without flashing nand:
https://gitorious.org/0xffff/0xffff

Well, it compiles, and seems to work. Includes extensive documentation, but...

How do I put the device into mode where it responds to 0xffff? It seems to be there for only a second after power off...?

n90- has very confusing startup sequence...

Quoted 2 lines

If you need help with booting some upstream kernel on n900 join to freenode #maemo-alternatives channel :-)

Hmm, I did, seems I'm alone there :-(.
Pavel
PS: I seem to need attached patches to get defconfig to compile:

arch/arm/mach-omap2/board-rx51-peripherals.c +1 -1
index 9fe4bdf..4aa13ce 100644
@@ -1037,7 +1037,7 @@ static struct hsi_board_info __initdata rx51_ssi_cl[] = {
 			.mode = HSI_MODE_FRAME,
 			.channels = 4,
 			.speed = 55000,
-			.arb_mode = HSI_ARB_RR,
+//			.arb_mode = HSI_ARB_RR,
 			},
 		.rx_cfg = {
 			.mode = HSI_MODE_FRAME,
arch/arm/mach-omap2/board-rx51-smc.S +1 -1
index 70e2eb7..bdfb2d7 100644
@@ -20,7 +20,7 @@
  *          with number of parametrs
  */
 ENTRY(rx51_ppa_smc)
-	.arch_extension sec
+//	.arch_extension sec
 	stmfd	sp!, {r4-r12, lr}
 	mov	r12, r0		@ Copy the secure service ID
 	mov	r3, r2		@ Copy the pointer to va_list in R3
drivers/char/hw_random/omap3-rom-asm.S +1 -1
index ce82e16..65d2b5e 100644
@@ -12,7 +12,7 @@
 #include <asm/assembler.h>
 
 ENTRY(omap3_rng_call_rom_asm)
-	.arch_extension sec
+//	.arch_extension sec
 	stmfd	sp!, {r4-r12, lr}
 	stmfd	sp!, {r0-r3}
 	bl	v7_flush_dcache_all
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#14 lore raw
In reply to Pali Rohár

Hi!

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

Thanks for the review, Pavel! Although, the patch is in Linus' tree long ago. ;-)

Yeah... I did a bit of history-digging ;-). Now, I should figure out how to put custom kernel on n900 _and_ keep it in working state at the same time.

Quoted 8 lines
Quoted 4 lines

(I installed some kind of multiboot, then, apt decided to install some u-boot extension. Then it got interesting. I never got my own kernel to work, and u-boot magically disappeared, but I still have working phone :-).

Hello Pavel,

here are some hints for booting 3.8+ kernel on n900:

Ok, I have compiled defconfig kernel (with patches, as indicated).

sudo src/0xFFFF -m /data/l/linux-n900/arch/arm/boot/zImage -l -b

seems to boot it, I see kernel messages scrolling, but it reboots instead of going to the GUI.

Quoted 5 lines

"multiboot" package from Maemo Extras is horrible hack which can be used only for booting maemo 2.6.28 kernel. it flashing new kernel to n900 nand, then reboot device, start maemo init and mount/chroot into new os dir... after reboot it erasing kernel nand area where is normaly uboot placed, so do not install it!

I had it already :-(. Removed now. I tried running custom kernel, but then multiboot interfered. I got u-boot installed with help from irc.

Unfortunately, the u-boot can not boot kernel-power, so I'm back to original kernel without tethering :-(.

Quoted 6 lines

uboot in Maemo Extras cannot boot 3.x kernels because autobuilder (Extras server app for buidling packages) has very old gcc which produced semi-(non)working uboot (can boot some 2.6 kernels).

my uboot builds compiled by gcc 4.7 (which can boot 3.8 kernel):
http://atrey.karlin.mff.cuni.cz/~pali/u-boot/

Can I get away with using u-boot package in the repositories?

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html