linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] rx1950: add rest of devices
@ 2010-09-07 14:32 Vasily Khoruzhick
  2010-09-07 14:32 ` [PATCH 1/3] rx1950: add battery device Vasily Khoruzhick
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Vasily Khoruzhick @ 2010-09-07 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

This series adds battery device, LEDs device and sound codec
device to mach-rx1950.c

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] rx1950: add battery device
  2010-09-07 14:32 [PATCH 0/3] rx1950: add rest of devices Vasily Khoruzhick
@ 2010-09-07 14:32 ` Vasily Khoruzhick
  2010-09-07 23:06   ` Ben Dooks
  2010-09-07 14:32 ` [PATCH 2/3] rx1950: add LEDs support Vasily Khoruzhick
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Vasily Khoruzhick @ 2010-09-07 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 arch/arm/mach-s3c2440/Kconfig       |    3 +
 arch/arm/mach-s3c2440/mach-rx1950.c |  160 +++++++++++++++++++++++++++++++++++
 2 files changed, 163 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2440/Kconfig b/arch/arm/mach-s3c2440/Kconfig
index cd8e7de..9b6b026 100644
--- a/arch/arm/mach-s3c2440/Kconfig
+++ b/arch/arm/mach-s3c2440/Kconfig
@@ -198,6 +198,9 @@ config MACH_RX1950
 	select S3C_DEV_NAND
 	select S3C2410_IOTIMING if S3C2440_CPUFREQ
 	select S3C2440_XTAL_16934400
+	select S3C_ADC
+	select PDA_POWER
+	select BATTERY_S3C_ADC
 	help
 	   Say Y here if you're using HP iPAQ rx1950
 
diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c
index 142d1f9..1197ab4 100644
--- a/arch/arm/mach-s3c2440/mach-rx1950.c
+++ b/arch/arm/mach-s3c2440/mach-rx1950.c
@@ -25,8 +25,10 @@
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
 #include <linux/sysdev.h>
+#include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/pwm.h>
+#include <linux/s3c_adc_battery.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
@@ -127,6 +129,162 @@ static struct s3c2410fb_display rx1950_display = {
 
 };
 
+static int power_supply_init(struct device *dev)
+{
+	return gpio_request(S3C2410_GPF(2), "cable plugged");
+}
+
+static int rx1950_is_ac_online(void)
+{
+	return !gpio_get_value(S3C2410_GPF(2));
+}
+
+static void power_supply_exit(struct device *dev)
+{
+	gpio_free(S3C2410_GPF(2));
+}
+
+static char *rx1950_supplicants[] = {
+	"main-battery"
+};
+
+static struct pda_power_pdata power_supply_info = {
+	.init				= power_supply_init,
+	.is_ac_online		= rx1950_is_ac_online,
+	.exit				= power_supply_exit,
+	.supplied_to		= rx1950_supplicants,
+	.num_supplicants	= ARRAY_SIZE(rx1950_supplicants),
+};
+
+static struct resource power_supply_resources[] = {
+	[0] = {
+			.name	= "ac",
+			.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE |
+					  IORESOURCE_IRQ_HIGHEDGE,
+			.start	= IRQ_EINT2,
+			.end	= IRQ_EINT2,
+	},
+};
+
+static struct platform_device power_supply = {
+	.name			= "pda-power",
+	.id				= -1,
+	.dev			= {
+						.platform_data =
+							&power_supply_info,
+	},
+	.resource		= power_supply_resources,
+	.num_resources	= ARRAY_SIZE(power_supply_resources),
+};
+
+static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
+	{4100, 156, 100},
+	{4050, 156, 95},
+	{4025, 141, 90},
+	{3995, 144, 85},
+	{3957, 162, 80},
+	{3931, 147, 75},
+	{3902, 147, 70},
+	{3863, 153, 65},
+	{3838, 150, 60},
+	{3800, 153, 55},
+	{3765, 153, 50},
+	{3748, 172, 45},
+	{3740, 153, 40},
+	{3714, 175, 35},
+	{3710, 156, 30},
+	{3963, 156, 25},
+	{3672, 178, 20},
+	{3651, 178, 15},
+	{3629, 178, 10},
+	{3612, 162, 5},
+	{3605, 162, 0},
+};
+
+static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
+	{4200, 0, 100},
+	{4190, 0, 99},
+	{4178, 0, 95},
+	{4110, 0, 70},
+	{4076, 0, 65},
+	{4046, 0, 60},
+	{4021, 0, 55},
+	{3999, 0, 50},
+	{3982, 0, 45},
+	{3965, 0, 40},
+	{3957, 0, 35},
+	{3948, 0, 30},
+	{3936, 0, 25},
+	{3927, 0, 20},
+	{3906, 0, 15},
+	{3880, 0, 10},
+	{3829, 0, 5},
+	{3820, 0, 0},
+};
+
+int rx1950_bat_init(void)
+{
+	int ret;
+
+	ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
+	if (ret)
+		goto err_gpio1;
+	ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
+	if (ret)
+		goto err_gpio2;
+
+	return 0;
+
+err_gpio2:
+	gpio_free(S3C2410_GPJ(2));
+err_gpio1:
+	return ret;
+}
+
+void rx1950_bat_exit(void)
+{
+	gpio_free(S3C2410_GPJ(2));
+	gpio_free(S3C2410_GPJ(3));
+}
+
+void rx1950_enable_charger(void)
+{
+	gpio_direction_output(S3C2410_GPJ(2), 1);
+	gpio_direction_output(S3C2410_GPJ(3), 1);
+}
+
+void rx1950_disable_charger(void)
+{
+	gpio_direction_output(S3C2410_GPJ(2), 0);
+	gpio_direction_output(S3C2410_GPJ(3), 0);
+}
+
+static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
+	.init = rx1950_bat_init,
+	.exit = rx1950_bat_exit,
+	.enable_charger = rx1950_enable_charger,
+	.disable_charger = rx1950_disable_charger,
+	.gpio_charge_finished = S3C2410_GPF(3),
+	.lut_noac = bat_lut_noac,
+	.lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
+	.lut_acin = bat_lut_acin,
+	.lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
+	.volt_channel = 0,
+	.current_channel = 1,
+	.volt_mult = 4235,
+	.current_mult = 2900,
+	.internal_impedance = 200,
+};
+
+static struct platform_device rx1950_battery = {
+	.name             = "s3c-adc-battery",
+	.id               = -1,
+	.dev = {
+		.parent = &s3c_device_adc.dev,
+		.platform_data = &rx1950_bat_cfg,
+	},
+};
+
 static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
 	.displays = &rx1950_display,
 	.num_displays = 1,
@@ -503,6 +661,8 @@ static struct platform_device *rx1950_devices[] __initdata = {
 	&s3c_device_timer[1],
 	&rx1950_backlight,
 	&rx1950_device_gpiokeys,
+	&power_supply,
+	&rx1950_battery,
 };
 
 static struct clk *rx1950_clocks[] __initdata = {
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] rx1950: add LEDs support
  2010-09-07 14:32 [PATCH 0/3] rx1950: add rest of devices Vasily Khoruzhick
  2010-09-07 14:32 ` [PATCH 1/3] rx1950: add battery device Vasily Khoruzhick
@ 2010-09-07 14:32 ` Vasily Khoruzhick
  2010-09-07 14:32 ` [PATCH 3/3] rx1950: add UDA1380 to i2c devices list Vasily Khoruzhick
  2010-09-07 23:07 ` [PATCH 0/3] rx1950: add rest of devices Ben Dooks
  3 siblings, 0 replies; 10+ messages in thread
From: Vasily Khoruzhick @ 2010-09-07 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 arch/arm/mach-s3c2440/mach-rx1950.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c
index 1197ab4..3328c86 100644
--- a/arch/arm/mach-s3c2440/mach-rx1950.c
+++ b/arch/arm/mach-s3c2440/mach-rx1950.c
@@ -29,6 +29,7 @@
 #include <linux/pwm_backlight.h>
 #include <linux/pwm.h>
 #include <linux/s3c_adc_battery.h>
+#include <linux/leds.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
@@ -259,6 +260,37 @@ void rx1950_disable_charger(void)
 	gpio_direction_output(S3C2410_GPJ(3), 0);
 }
 
+static struct gpio_led rx1950_leds_desc[] = {
+	{
+		.name				= "Green",
+		.default_trigger	= "main-battery-charging-or-full",
+		.gpio				= S3C2410_GPA(6),
+	},
+	{
+		.name				= "Red",
+		.default_trigger	= "main-battery-full",
+		.gpio				= S3C2410_GPA(7),
+	},
+	{
+		.name				= "Blue",
+		.default_trigger	= "rx1950-acx-mem",
+		.gpio				= S3C2410_GPA(11),
+	},
+};
+
+static struct gpio_led_platform_data rx1950_leds_pdata = {
+	.num_leds	= ARRAY_SIZE(rx1950_leds_desc),
+	.leds		= rx1950_leds_desc,
+};
+
+static struct platform_device rx1950_leds = {
+	.name	= "leds-gpio",
+	.id		= -1,
+	.dev	= {
+				.platform_data = &rx1950_leds_pdata,
+	},
+};
+
 static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
 	.init = rx1950_bat_init,
 	.exit = rx1950_bat_exit,
@@ -663,6 +695,7 @@ static struct platform_device *rx1950_devices[] __initdata = {
 	&rx1950_device_gpiokeys,
 	&power_supply,
 	&rx1950_battery,
+	&rx1950_leds,
 };
 
 static struct clk *rx1950_clocks[] __initdata = {
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] rx1950: add UDA1380 to i2c devices list
  2010-09-07 14:32 [PATCH 0/3] rx1950: add rest of devices Vasily Khoruzhick
  2010-09-07 14:32 ` [PATCH 1/3] rx1950: add battery device Vasily Khoruzhick
  2010-09-07 14:32 ` [PATCH 2/3] rx1950: add LEDs support Vasily Khoruzhick
@ 2010-09-07 14:32 ` Vasily Khoruzhick
  2010-09-07 23:07 ` [PATCH 0/3] rx1950: add rest of devices Ben Dooks
  3 siblings, 0 replies; 10+ messages in thread
From: Vasily Khoruzhick @ 2010-09-07 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 arch/arm/mach-s3c2440/mach-rx1950.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c
index 3328c86..d971aa9 100644
--- a/arch/arm/mach-s3c2440/mach-rx1950.c
+++ b/arch/arm/mach-s3c2440/mach-rx1950.c
@@ -30,6 +30,7 @@
 #include <linux/pwm.h>
 #include <linux/s3c_adc_battery.h>
 #include <linux/leds.h>
+#include <linux/i2c.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
@@ -58,6 +59,8 @@
 #include <plat/irq.h>
 #include <plat/ts.h>
 
+#include <sound/uda1380.h>
+
 #define LCD_PWM_PERIOD 192960
 #define LCD_PWM_DUTY 127353
 
@@ -671,11 +674,17 @@ static struct platform_device rx1950_device_gpiokeys = {
 	.dev.platform_data = &rx1950_gpio_keys_data,
 };
 
-static struct s3c2410_platform_i2c rx1950_i2c_data = {
-	.flags = 0,
-	.slave_addr = 0x42,
-	.frequency = 400 * 1000,
-	.sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON,
+static struct uda1380_platform_data uda1380_info = {
+	.gpio_power	= S3C2410_GPJ(0),
+	.gpio_reset	= S3C2410_GPD(0),
+	.dac_clk	= UDA1380_DAC_CLK_SYSCLK,
+};
+
+static struct i2c_board_info rx1950_i2c_devices[] = {
+	{
+		I2C_BOARD_INFO("uda1380", 0x1a),
+		.platform_data = &uda1380_info,
+	},
 };
 
 static struct platform_device *rx1950_devices[] __initdata = {
@@ -683,6 +692,7 @@ static struct platform_device *rx1950_devices[] __initdata = {
 	&s3c_device_wdt,
 	&s3c_device_i2c0,
 	&s3c_device_iis,
+	&s3c_device_pcm,
 	&s3c_device_usbgadget,
 	&s3c_device_rtc,
 	&s3c_device_nand,
@@ -731,7 +741,7 @@ static void __init rx1950_init_machine(void)
 	s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
 	s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
 	s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
-	s3c_i2c0_set_platdata(&rx1950_i2c_data);
+	s3c_i2c0_set_platdata(NULL);
 	s3c_nand_set_platdata(&rx1950_nand_info);
 
 	/* Turn off suspend on both USB ports, and switch the
@@ -762,6 +772,9 @@ static void __init rx1950_init_machine(void)
 	WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
 
 	platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
+
+	i2c_register_board_info(0, rx1950_i2c_devices,
+		ARRAY_SIZE(rx1950_i2c_devices));
 }
 
 /* H1940 and RX3715 need to reserve this for suspend */
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 1/3] rx1950: add battery device
  2010-09-07 14:32 ` [PATCH 1/3] rx1950: add battery device Vasily Khoruzhick
@ 2010-09-07 23:06   ` Ben Dooks
  2010-09-07 23:10     ` Vasily Khoruzhick
  2010-09-08  8:58     ` [PATCH v2 " Vasily Khoruzhick
  0 siblings, 2 replies; 10+ messages in thread
From: Ben Dooks @ 2010-09-07 23:06 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/09/10 15:32, Vasily Khoruzhick wrote:
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
>  arch/arm/mach-s3c2440/Kconfig       |    3 +
>  arch/arm/mach-s3c2440/mach-rx1950.c |  160 +++++++++++++++++++++++++++++++++++
>  2 files changed, 163 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-s3c2440/Kconfig b/arch/arm/mach-s3c2440/Kconfig
> index cd8e7de..9b6b026 100644
> --- a/arch/arm/mach-s3c2440/Kconfig
> +++ b/arch/arm/mach-s3c2440/Kconfig
> @@ -198,6 +198,9 @@ config MACH_RX1950
>  	select S3C_DEV_NAND
>  	select S3C2410_IOTIMING if S3C2440_CPUFREQ
>  	select S3C2440_XTAL_16934400
> +	select S3C_ADC
> +	select PDA_POWER
> +	select BATTERY_S3C_ADC

not keen on forcing these on unless they are required for the
system to work.

>  	help
>  	   Say Y here if you're using HP iPAQ rx1950
>  
> diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c
> index 142d1f9..1197ab4 100644
> --- a/arch/arm/mach-s3c2440/mach-rx1950.c
> +++ b/arch/arm/mach-s3c2440/mach-rx1950.c
> @@ -25,8 +25,10 @@

> +
> +static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
> +	{4100, 156, 100},
> +	{4050, 156, 95},
> +	{4025, 141, 90},
> +	{3995, 144, 85},
> +	{3957, 162, 80},
> +	{3931, 147, 75},
> +	{3902, 147, 70},
> +	{3863, 153, 65},
> +	{3838, 150, 60},
> +	{3800, 153, 55},
> +	{3765, 153, 50},
> +	{3748, 172, 45},
> +	{3740, 153, 40},
> +	{3714, 175, 35},
> +	{3710, 156, 30},
> +	{3963, 156, 25},
> +	{3672, 178, 20},
> +	{3651, 178, 15},
> +	{3629, 178, 10},
> +	{3612, 162, 5},
> +	{3605, 162, 0},
> +

at least add a space after { and before }
it would be nice to have named initialisers.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 0/3] rx1950: add rest of devices
  2010-09-07 14:32 [PATCH 0/3] rx1950: add rest of devices Vasily Khoruzhick
                   ` (2 preceding siblings ...)
  2010-09-07 14:32 ` [PATCH 3/3] rx1950: add UDA1380 to i2c devices list Vasily Khoruzhick
@ 2010-09-07 23:07 ` Ben Dooks
  3 siblings, 0 replies; 10+ messages in thread
From: Ben Dooks @ 2010-09-07 23:07 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/09/10 15:32, Vasily Khoruzhick wrote:
> This series adds battery device, LEDs device and sound codec
> device to mach-rx1950.c

the first one has a few issues, the others look fine.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] rx1950: add battery device
  2010-09-07 23:06   ` Ben Dooks
@ 2010-09-07 23:10     ` Vasily Khoruzhick
  2010-09-08  8:58     ` [PATCH v2 " Vasily Khoruzhick
  1 sibling, 0 replies; 10+ messages in thread
From: Vasily Khoruzhick @ 2010-09-07 23:10 UTC (permalink / raw)
  To: linux-arm-kernel

? ????????? ?? 8 ???????? 2010 02:06:19 ????? Ben Dooks ???????:
> On 07/09/10 15:32, Vasily Khoruzhick wrote:
> > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> > ---
> > 
> >  arch/arm/mach-s3c2440/Kconfig       |    3 +
> >  arch/arm/mach-s3c2440/mach-rx1950.c |  160
> >  +++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+),
> >  0 deletions(-)
> > 
> > diff --git a/arch/arm/mach-s3c2440/Kconfig
> > b/arch/arm/mach-s3c2440/Kconfig index cd8e7de..9b6b026 100644
> > --- a/arch/arm/mach-s3c2440/Kconfig
> > +++ b/arch/arm/mach-s3c2440/Kconfig
> > @@ -198,6 +198,9 @@ config MACH_RX1950
> > 
> >  	select S3C_DEV_NAND
> >  	select S3C2410_IOTIMING if S3C2440_CPUFREQ
> >  	select S3C2440_XTAL_16934400
> > 
> > +	select S3C_ADC
> > +	select PDA_POWER
> > +	select BATTERY_S3C_ADC
> 
> not keen on forcing these on unless they are required for the
> system to work.

Ok

> > +	{3629, 178, 10},
> > +	{3612, 162, 5},
> > +	{3605, 162, 0},
> > +
> 
> at least add a space after { and before }
> it would be nice to have named initialisers.

Ok, I'll add named initialisers

Regards
Vasily
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100908/c04cdb87/attachment.sig>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/3] rx1950: add battery device
  2010-09-07 23:06   ` Ben Dooks
  2010-09-07 23:10     ` Vasily Khoruzhick
@ 2010-09-08  8:58     ` Vasily Khoruzhick
  2010-09-25 23:48       ` Ben Dooks
  1 sibling, 1 reply; 10+ messages in thread
From: Vasily Khoruzhick @ 2010-09-08  8:58 UTC (permalink / raw)
  To: linux-arm-kernel

v2: don't force usage of battery driver,
use named initialisers in LUTs.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 arch/arm/mach-s3c2440/mach-rx1950.c |  316 +++++++++++++++++++++++++++++++++++
 1 files changed, 316 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c
index 142d1f9..2bfa43a 100644
--- a/arch/arm/mach-s3c2440/mach-rx1950.c
+++ b/arch/arm/mach-s3c2440/mach-rx1950.c
@@ -25,8 +25,10 @@
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
 #include <linux/sysdev.h>
+#include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/pwm.h>
+#include <linux/s3c_adc_battery.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
@@ -127,6 +129,318 @@ static struct s3c2410fb_display rx1950_display = {
 
 };
 
+static int power_supply_init(struct device *dev)
+{
+	return gpio_request(S3C2410_GPF(2), "cable plugged");
+}
+
+static int rx1950_is_ac_online(void)
+{
+	return !gpio_get_value(S3C2410_GPF(2));
+}
+
+static void power_supply_exit(struct device *dev)
+{
+	gpio_free(S3C2410_GPF(2));
+}
+
+static char *rx1950_supplicants[] = {
+	"main-battery"
+};
+
+static struct pda_power_pdata power_supply_info = {
+	.init			= power_supply_init,
+	.is_ac_online		= rx1950_is_ac_online,
+	.exit			= power_supply_exit,
+	.supplied_to		= rx1950_supplicants,
+	.num_supplicants	= ARRAY_SIZE(rx1950_supplicants),
+};
+
+static struct resource power_supply_resources[] = {
+	[0] = {
+			.name	= "ac",
+			.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE |
+					  IORESOURCE_IRQ_HIGHEDGE,
+			.start	= IRQ_EINT2,
+			.end	= IRQ_EINT2,
+	},
+};
+
+static struct platform_device power_supply = {
+	.name			= "pda-power",
+	.id			= -1,
+	.dev			= {
+					.platform_data =
+						&power_supply_info,
+	},
+	.resource		= power_supply_resources,
+	.num_resources		= ARRAY_SIZE(power_supply_resources),
+};
+
+static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
+	{
+		.volt = 4100,
+		.cur = 156,
+		.level = 100
+	},
+	{
+		.volt = 4050,
+		.cur = 156,
+		.level = 95
+	},
+	{
+		.volt = 4025,
+		.cur = 141,
+		.level = 90
+	},
+	{
+		.volt = 3995,
+		.cur = 144,
+		.level = 85
+	},
+	{
+		.volt = 3957,
+		.cur = 162,
+		.level = 80
+	},
+	{
+		.volt = 3931,
+		.cur = 147,
+		.level = 75
+	},
+	{
+		.volt = 3902,
+		.cur = 147,
+		.level = 70
+	},
+	{
+		.volt = 3863,
+		.cur = 153,
+		.level = 65
+	},
+	{
+		.volt = 3838,
+		.cur = 150,
+		.level = 60
+	},
+	{
+		.volt = 3800,
+		.cur = 153,
+		.level = 55
+	},
+	{
+		.volt = 3765,
+		.cur = 153,
+		.level = 50
+	},
+	{
+		.volt = 3748,
+		.cur = 172,
+		.level = 45
+	},
+	{
+		.volt = 3740,
+		.cur = 153,
+		.level = 40
+	},
+	{
+		.volt = 3714,
+		.cur = 175,
+		.level = 35
+	},
+	{
+		.volt = 3710,
+		.cur = 156,
+		.level = 30
+	},
+	{
+		.volt = 3963,
+		.cur = 156,
+		.level = 25
+	},
+	{
+		.volt = 3672,
+		.cur = 178,
+		.level = 20
+	},
+	{
+		.volt = 3651,
+		.cur = 178,
+		.level = 15
+	},
+	{
+		.volt = 3629,
+		.cur = 178,
+		.level = 10
+	},
+	{
+		.volt = 3612,
+		.cur = 162,
+		.level = 5
+	},
+	{
+		.volt = 3605,
+		.cur = 162,
+		.level = 0
+	},
+};
+
+static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
+	{
+		.volt = 4200,
+		.cur = 0,
+		.level = 100
+	},
+	{
+		.volt = 4190,
+		.cur = 0,
+		.level = 99
+	},
+	{
+		.volt = 4178,
+		.cur = 0,
+		.level = 95
+	},
+	{
+		.volt = 4110,
+		.cur = 0,
+		.level = 70
+	},
+	{
+		.volt = 4076,
+		.cur = 0,
+		.level = 65
+	},
+	{
+		.volt = 4046,
+		.cur = 0,
+		.level = 60
+	},
+	{
+		.volt = 4021,
+		.cur = 0,
+		.level = 55
+	},
+	{
+		.volt = 3999,
+		.cur = 0,
+		.level = 50
+	},
+	{
+		.volt = 3982,
+		.cur = 0,
+		.level = 45
+	},
+	{
+		.volt = 3965,
+		.cur = 0,
+		.level = 40
+	},
+	{
+		.volt = 3957,
+		.cur = 0,
+		.level = 35
+	},
+	{
+		.volt = 3948,
+		.cur = 0,
+		.level = 30
+	},
+	{
+		.volt = 3936,
+		.cur = 0,
+		.level = 25
+	},
+	{
+		.volt = 3927,
+		.cur = 0,
+		.level = 20
+	},
+	{
+		.volt = 3906,
+		.cur = 0,
+		.level = 15
+	},
+	{
+		.volt = 3880,
+		.cur = 0,
+		.level = 10
+	},
+	{
+		.volt = 3829,
+		.cur = 0,
+		.level = 5
+	},
+	{
+		.volt = 3820,
+		.cur = 0,
+		.level = 0
+	},
+};
+
+int rx1950_bat_init(void)
+{
+	int ret;
+
+	ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
+	if (ret)
+		goto err_gpio1;
+	ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
+	if (ret)
+		goto err_gpio2;
+
+	return 0;
+
+err_gpio2:
+	gpio_free(S3C2410_GPJ(2));
+err_gpio1:
+	return ret;
+}
+
+void rx1950_bat_exit(void)
+{
+	gpio_free(S3C2410_GPJ(2));
+	gpio_free(S3C2410_GPJ(3));
+}
+
+void rx1950_enable_charger(void)
+{
+	gpio_direction_output(S3C2410_GPJ(2), 1);
+	gpio_direction_output(S3C2410_GPJ(3), 1);
+}
+
+void rx1950_disable_charger(void)
+{
+	gpio_direction_output(S3C2410_GPJ(2), 0);
+	gpio_direction_output(S3C2410_GPJ(3), 0);
+}
+
+static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
+	.init = rx1950_bat_init,
+	.exit = rx1950_bat_exit,
+	.enable_charger = rx1950_enable_charger,
+	.disable_charger = rx1950_disable_charger,
+	.gpio_charge_finished = S3C2410_GPF(3),
+	.lut_noac = bat_lut_noac,
+	.lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
+	.lut_acin = bat_lut_acin,
+	.lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
+	.volt_channel = 0,
+	.current_channel = 1,
+	.volt_mult = 4235,
+	.current_mult = 2900,
+	.internal_impedance = 200,
+};
+
+static struct platform_device rx1950_battery = {
+	.name             = "s3c-adc-battery",
+	.id               = -1,
+	.dev = {
+		.parent = &s3c_device_adc.dev,
+		.platform_data = &rx1950_bat_cfg,
+	},
+};
+
 static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
 	.displays = &rx1950_display,
 	.num_displays = 1,
@@ -503,6 +817,8 @@ static struct platform_device *rx1950_devices[] __initdata = {
 	&s3c_device_timer[1],
 	&rx1950_backlight,
 	&rx1950_device_gpiokeys,
+	&power_supply,
+	&rx1950_battery,
 };
 
 static struct clk *rx1950_clocks[] __initdata = {
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 1/3] rx1950: add battery device
  2010-09-08  8:58     ` [PATCH v2 " Vasily Khoruzhick
@ 2010-09-25 23:48       ` Ben Dooks
  2010-09-26 21:17         ` [PATCH v3 " Vasily Khoruzhick
  0 siblings, 1 reply; 10+ messages in thread
From: Ben Dooks @ 2010-09-25 23:48 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/09/10 09:58, Vasily Khoruzhick wrote:
> v2: don't force usage of battery driver,
> use named initialisers in LUTs.

Any chance of more description here?


> +
> +static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
> +	{
> +		.volt = 4100,
> +		.cur = 156,
> +		.level = 100
> +	},

In this case I'd say we may as well do the following
	{ .volt = 4100, .cur = 156, .level = 100 },

given there so many of them.

-- 
Ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 1/3] rx1950: add battery device
  2010-09-25 23:48       ` Ben Dooks
@ 2010-09-26 21:17         ` Vasily Khoruzhick
  0 siblings, 0 replies; 10+ messages in thread
From: Vasily Khoruzhick @ 2010-09-26 21:17 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds registration of appropriate device for
s3c-adc-battery driver, so battery monitoring and charging are
available on RX1950 PDA now.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
v2: don't force usage of battery driver,
use named initialisers in LUTs.

v3: add comment to patch, make LUTs look tiny again.

 arch/arm/mach-s3c2440/mach-rx1950.c |  160 +++++++++++++++++++++++++++++++++++
 1 files changed, 160 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c
index 142d1f9..a4d8c15 100644
--- a/arch/arm/mach-s3c2440/mach-rx1950.c
+++ b/arch/arm/mach-s3c2440/mach-rx1950.c
@@ -25,8 +25,10 @@
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
 #include <linux/sysdev.h>
+#include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/pwm.h>
+#include <linux/s3c_adc_battery.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
@@ -127,6 +129,162 @@ static struct s3c2410fb_display rx1950_display = {
 
 };
 
+static int power_supply_init(struct device *dev)
+{
+	return gpio_request(S3C2410_GPF(2), "cable plugged");
+}
+
+static int rx1950_is_ac_online(void)
+{
+	return !gpio_get_value(S3C2410_GPF(2));
+}
+
+static void power_supply_exit(struct device *dev)
+{
+	gpio_free(S3C2410_GPF(2));
+}
+
+static char *rx1950_supplicants[] = {
+	"main-battery"
+};
+
+static struct pda_power_pdata power_supply_info = {
+	.init			= power_supply_init,
+	.is_ac_online		= rx1950_is_ac_online,
+	.exit			= power_supply_exit,
+	.supplied_to		= rx1950_supplicants,
+	.num_supplicants	= ARRAY_SIZE(rx1950_supplicants),
+};
+
+static struct resource power_supply_resources[] = {
+	[0] = {
+			.name	= "ac",
+			.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE |
+					  IORESOURCE_IRQ_HIGHEDGE,
+			.start	= IRQ_EINT2,
+			.end	= IRQ_EINT2,
+	},
+};
+
+static struct platform_device power_supply = {
+	.name			= "pda-power",
+	.id			= -1,
+	.dev			= {
+					.platform_data =
+						&power_supply_info,
+	},
+	.resource		= power_supply_resources,
+	.num_resources		= ARRAY_SIZE(power_supply_resources),
+};
+
+static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
+	{ .volt = 4100, .cur = 156, .level = 100},
+	{ .volt = 4050, .cur = 156, .level = 95},
+	{ .volt = 4025, .cur = 141, .level = 90},
+	{ .volt = 3995, .cur = 144, .level = 85},
+	{ .volt = 3957, .cur = 162, .level = 80},
+	{ .volt = 3931, .cur = 147, .level = 75},
+	{ .volt = 3902, .cur = 147, .level = 70},
+	{ .volt = 3863, .cur = 153, .level = 65},
+	{ .volt = 3838, .cur = 150, .level = 60},
+	{ .volt = 3800, .cur = 153, .level = 55},
+	{ .volt = 3765, .cur = 153, .level = 50},
+	{ .volt = 3748, .cur = 172, .level = 45},
+	{ .volt = 3740, .cur = 153, .level = 40},
+	{ .volt = 3714, .cur = 175, .level = 35},
+	{ .volt = 3710, .cur = 156, .level = 30},
+	{ .volt = 3963, .cur = 156, .level = 25},
+	{ .volt = 3672, .cur = 178, .level = 20},
+	{ .volt = 3651, .cur = 178, .level = 15},
+	{ .volt = 3629, .cur = 178, .level = 10},
+	{ .volt = 3612, .cur = 162, .level = 5},
+	{ .volt = 3605, .cur = 162, .level = 0},
+};
+
+static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
+	{ .volt = 4200, .cur = 0, .level = 100},
+	{ .volt = 4190, .cur = 0, .level = 99},
+	{ .volt = 4178, .cur = 0, .level = 95},
+	{ .volt = 4110, .cur = 0, .level = 70},
+	{ .volt = 4076, .cur = 0, .level = 65},
+	{ .volt = 4046, .cur = 0, .level = 60},
+	{ .volt = 4021, .cur = 0, .level = 55},
+	{ .volt = 3999, .cur = 0, .level = 50},
+	{ .volt = 3982, .cur = 0, .level = 45},
+	{ .volt = 3965, .cur = 0, .level = 40},
+	{ .volt = 3957, .cur = 0, .level = 35},
+	{ .volt = 3948, .cur = 0, .level = 30},
+	{ .volt = 3936, .cur = 0, .level = 25},
+	{ .volt = 3927, .cur = 0, .level = 20},
+	{ .volt = 3906, .cur = 0, .level = 15},
+	{ .volt = 3880, .cur = 0, .level = 10},
+	{ .volt = 3829, .cur = 0, .level = 5},
+	{ .volt = 3820, .cur = 0, .level = 0},
+};
+
+int rx1950_bat_init(void)
+{
+	int ret;
+
+	ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
+	if (ret)
+		goto err_gpio1;
+	ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
+	if (ret)
+		goto err_gpio2;
+
+	return 0;
+
+err_gpio2:
+	gpio_free(S3C2410_GPJ(2));
+err_gpio1:
+	return ret;
+}
+
+void rx1950_bat_exit(void)
+{
+	gpio_free(S3C2410_GPJ(2));
+	gpio_free(S3C2410_GPJ(3));
+}
+
+void rx1950_enable_charger(void)
+{
+	gpio_direction_output(S3C2410_GPJ(2), 1);
+	gpio_direction_output(S3C2410_GPJ(3), 1);
+}
+
+void rx1950_disable_charger(void)
+{
+	gpio_direction_output(S3C2410_GPJ(2), 0);
+	gpio_direction_output(S3C2410_GPJ(3), 0);
+}
+
+static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
+	.init = rx1950_bat_init,
+	.exit = rx1950_bat_exit,
+	.enable_charger = rx1950_enable_charger,
+	.disable_charger = rx1950_disable_charger,
+	.gpio_charge_finished = S3C2410_GPF(3),
+	.lut_noac = bat_lut_noac,
+	.lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
+	.lut_acin = bat_lut_acin,
+	.lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
+	.volt_channel = 0,
+	.current_channel = 1,
+	.volt_mult = 4235,
+	.current_mult = 2900,
+	.internal_impedance = 200,
+};
+
+static struct platform_device rx1950_battery = {
+	.name             = "s3c-adc-battery",
+	.id               = -1,
+	.dev = {
+		.parent = &s3c_device_adc.dev,
+		.platform_data = &rx1950_bat_cfg,
+	},
+};
+
 static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
 	.displays = &rx1950_display,
 	.num_displays = 1,
@@ -503,6 +661,8 @@ static struct platform_device *rx1950_devices[] __initdata = {
 	&s3c_device_timer[1],
 	&rx1950_backlight,
 	&rx1950_device_gpiokeys,
+	&power_supply,
+	&rx1950_battery,
 };
 
 static struct clk *rx1950_clocks[] __initdata = {
-- 
1.7.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-09-26 21:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-07 14:32 [PATCH 0/3] rx1950: add rest of devices Vasily Khoruzhick
2010-09-07 14:32 ` [PATCH 1/3] rx1950: add battery device Vasily Khoruzhick
2010-09-07 23:06   ` Ben Dooks
2010-09-07 23:10     ` Vasily Khoruzhick
2010-09-08  8:58     ` [PATCH v2 " Vasily Khoruzhick
2010-09-25 23:48       ` Ben Dooks
2010-09-26 21:17         ` [PATCH v3 " Vasily Khoruzhick
2010-09-07 14:32 ` [PATCH 2/3] rx1950: add LEDs support Vasily Khoruzhick
2010-09-07 14:32 ` [PATCH 3/3] rx1950: add UDA1380 to i2c devices list Vasily Khoruzhick
2010-09-07 23:07 ` [PATCH 0/3] rx1950: add rest of devices Ben Dooks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).