From ec18abc1a1dc9797392ba1d1fdbd30710bd3cab8 Mon Sep 17 00:00:00 2001 From: Maksim Kozlov Date: Thu, 17 May 2012 13:10:33 +0400 Subject: [PATCH] tizen: Added max17042 device to tizen board and enabled i2c2 interface --- arch/arm/configs/tizen_defconfig | 1 + arch/arm/mach-exynos/Kconfig | 2 + arch/arm/mach-exynos/include/mach/irqs.h | 1 + arch/arm/mach-exynos/mach-tizen.c | 74 +++++++++++++++--------- include/linux/power/max17042_battery.h | 5 ++ 5 files changed, 57 insertions(+), 26 deletions(-) diff --git a/arch/arm/configs/tizen_defconfig b/arch/arm/configs/tizen_defconfig index 1dc2fd6bf271..bc159aa95c83 100644 --- a/arch/arm/configs/tizen_defconfig +++ b/arch/arm/configs/tizen_defconfig @@ -311,6 +311,7 @@ CONFIG_S3C_DEV_HSMMC1=y CONFIG_S3C_DEV_HSMMC2=y CONFIG_S3C_DEV_HSMMC3=y CONFIG_S3C_DEV_I2C1=y +CONFIG_S3C_DEV_I2C2=y CONFIG_S3C_DEV_I2C3=y CONFIG_S3C_DEV_I2C5=y CONFIG_S3C_DEV_I2C6=y diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig index d97fecc1dfad..59a67d8e4318 100644 --- a/arch/arm/mach-exynos/Kconfig +++ b/arch/arm/mach-exynos/Kconfig @@ -316,6 +316,7 @@ config MACH_TIZEN select S3C_DEV_HSMMC2 select S3C_DEV_HSMMC3 select S3C_DEV_I2C1 + select S3C_DEV_I2C2 select S3C_DEV_I2C3 select S3C_DEV_I2C5 select S3C_DEV_I2C6 @@ -333,6 +334,7 @@ config MACH_TIZEN select EXYNOS4_SETUP_FIMC select EXYNOS4_SETUP_FIMD0 select EXYNOS4_SETUP_I2C1 + select EXYNOS4_SETUP_I2C2 select EXYNOS4_SETUP_I2C3 select EXYNOS4_SETUP_I2C5 select EXYNOS4_SETUP_I2C6 diff --git a/arch/arm/mach-exynos/include/mach/irqs.h b/arch/arm/mach-exynos/include/mach/irqs.h index 591e78521a9f..88740ec1bbcd 100644 --- a/arch/arm/mach-exynos/include/mach/irqs.h +++ b/arch/arm/mach-exynos/include/mach/irqs.h @@ -183,6 +183,7 @@ #define IRQ_IIC EXYNOS4_IRQ_IIC #define IRQ_IIC1 EXYNOS4_IRQ_IIC1 +#define IRQ_IIC2 EXYNOS4_IRQ_IIC2 #define IRQ_IIC3 EXYNOS4_IRQ_IIC3 #define IRQ_IIC5 EXYNOS4_IRQ_IIC5 #define IRQ_IIC6 EXYNOS4_IRQ_IIC6 diff --git a/arch/arm/mach-exynos/mach-tizen.c b/arch/arm/mach-exynos/mach-tizen.c index 9128a46f4cfb..0326e2c02b9e 100644 --- a/arch/arm/mach-exynos/mach-tizen.c +++ b/arch/arm/mach-exynos/mach-tizen.c @@ -370,6 +370,51 @@ static struct i2c_board_info i2c1_devs[] __initdata = { }, }; +/* I2C2 (Fuel Gauge) */ +static struct max17042_reg_data max17042_init_data[] = { + { MAX17042_CGAIN, 0x0000 }, + { MAX17042_MiscCFG, 0x0003 }, + { MAX17042_LearnCFG, 0x0007 }, + /* RCOMP: 0x0050 2011.02.29 from MAXIM */ + { MAX17042_RCOMP0, 0x0050 }, +}; + +/* Alert only when the battery is removed or inserted */ +static struct max17042_reg_data max17042_alert_init_data[] = { + /* SALRT Threshold setting (disable) unsigned MAX/MIN */ + { MAX17042_SALRT_Th, 0xFF00 }, + /* VALRT Threshold setting (disable) unsigned MAX/MIN */ + { MAX17042_VALRT_Th, 0xFF00 }, + /* TALRT Threshold setting (disable) signed MAX/MIN */ + { MAX17042_TALRT_Th, 0x7F80 }, +}; + +static struct max17042_platform_data tizen_battery_platform_data = { + .init_data = max17042_init_data, + .num_init_data = ARRAY_SIZE(max17042_init_data), + .alrt_data = max17042_alert_init_data, + .num_alrt_data = ARRAY_SIZE(max17042_alert_init_data), +// .irq_base = IRQ_FUEL_BASE, + .enable_alert = true, + .wakeup = true, + .r_sns = 10000, /* 10m Ohm */ +}; + +static struct s3c2410_platform_i2c i2c2_data __initdata = { + .flags = 0, + .bus_num = 2, + .slave_addr = 0x10, + .frequency = 400000U, + .sda_delay = 200, +}; + +static struct i2c_board_info i2c2_devs[] __initdata = { + { + I2C_BOARD_INFO("max17042", 0x36), + .platform_data = &tizen_battery_platform_data, + }, +}; + /* TSP */ static struct mxt_platform_data mxt_platform_data = { .x_line = 18, @@ -1023,29 +1068,6 @@ static struct i2c_board_info i2c5_devs[] __initdata = { }, }; -static struct max17042_platform_data tizen_battery_platform_data = { -}; - -/* GPIO I2C 9 (Fuel Gauge) */ -static struct i2c_gpio_platform_data i2c9_gpio_data = { - .sda_pin = EXYNOS4_GPY4(0), /* XM0ADDR_8 */ - .scl_pin = EXYNOS4_GPY4(1), /* XM0ADDR_9 */ -}; -static struct platform_device i2c9_gpio = { - .name = "i2c-gpio", - .id = 9, - .dev = { - .platform_data = &i2c9_gpio_data, - }, -}; -enum { I2C9_MAX17042}; -static struct i2c_board_info i2c9_devs[] __initdata = { - [I2C9_MAX17042] = { - I2C_BOARD_INFO("max17042", 0x36), - .platform_data = &tizen_battery_platform_data, - }, -}; - /* MAX8903 Secondary Charger */ static struct regulator_consumer_supply supplies_max8903[] = { REGULATOR_SUPPLY("vinchg2", "charger-manager.0"), @@ -1345,7 +1367,6 @@ static struct platform_device *tizen_devices[] __initdata = { &s3c_device_timer[0], &s5p_device_ehci, &s3c_device_i2c3, - &i2c9_gpio, &s3c_device_adc, &s5p_device_g2d, &s5p_device_jpeg, @@ -1371,6 +1392,7 @@ static struct platform_device *tizen_devices[] __initdata = { &cam_8m_12v_fixed_rdev, &exynos4_bus_devfreq, &s3c_device_i2c1, + &s3c_device_i2c2, &exynos4_device_i2s0, &samsung_asoc_idma, }; @@ -1397,13 +1419,13 @@ static void __init tizen_machine_init(void) s3c_i2c0_set_platdata(&tizen_i2c0_platdata); s3c_i2c1_set_platdata(NULL); i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs)); + s3c_i2c2_set_platdata(&i2c2_data); + i2c_register_board_info(2, i2c2_devs, ARRAY_SIZE(i2c2_devs)); s3c_i2c3_set_platdata(&i2c3_data); i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs)); s3c_i2c5_set_platdata(NULL); i2c5_devs[I2C5_MAX8997].irq = gpio_to_irq(EXYNOS4_GPX0(7)); i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs)); - i2c9_devs[I2C9_MAX17042].irq = gpio_to_irq(EXYNOS4_GPX2(3)); - i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs)); s3c_i2c6_set_platdata(&tizen_i2c6_platdata); s5p_fimd0_set_platdata(&tizen_fb_pdata); diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h index e01b167e66f0..7b46bc0d16bd 100644 --- a/include/linux/power/max17042_battery.h +++ b/include/linux/power/max17042_battery.h @@ -181,10 +181,15 @@ struct max17042_config_data { struct max17042_platform_data { struct max17042_reg_data *init_data; struct max17042_config_data *config_data; + struct max17042_reg_data *alrt_data; /* used if IRQ is enabled by I2C */ int num_init_data; /* Number of enties in init_data array */ + int num_alrt_data; bool enable_current_sense; bool enable_por_init; /* Use POR init from Maxim appnote */ + bool enable_alert; + bool wakeup; + /* * R_sns in micro-ohms. * default 10000 (if r_sns = 0) as it is the recommended value by -- 2.34.1