All, Based on our understanding/experiences till so far, we suggest the following: a) Remove all the PMIC-board related stuff from the EVM specific file ( like board-omap3evm.c) and keep it in a separate file (board-omap3evm- pmic.c). All platform related Inits should be done here. b) PMIC initialization and other PMIC specific routines (enable/disable, get/set voltage/current) should be done in the PMIC specific file like drivers/regulator/pmic.c c) Probing for PMIC during runtime could be done in either of the ways specified in the attached sample template. d) Generic wrappers should be provided to have a consistent interface for accessing PMIC registers and to use its supported features. Please find attached the sample implementation of the things mentioned above and provide your feedback. Thanks and Regards, Anuj Aggarwal Platform Support Products Texas Instruments Incorporated
/* * linux/arch/arm/mach-omap2/board-omap3evm-pmic.c * * Copyright (C) 2009 Texas Instruments Incorporated * * <tbd> copyright */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/platform_device.h> #include <linux/i2c/twl4030.h> #include <linux/i2c/tps6535x.h> /* --- other generic headers --- */ /* * * If we are okay with controlled ifdef in this file then we can follow * the scheme below... * */ #ifdef CONFIG_TWL4030_CORE /* * Definitions specific to TWL4030 */ #endif /* CONFIG_TWL4030_CORE */ #ifdef CONFIG_PMIC_TPS62350 /* * Definitions specific to TPS62350 */ #endif /* CONFIG_PMIC_TPS62350 */ #ifdef CONFIG_PMIC_TPS65023 /* * Definitions specific to TPS65023 */ #endif /* CONFIG_PMIC_TPS65023 */ int omap3_evm_pmic_init() { #ifdef CONFIG_TWL4030_CORE /* do stuff specific to TWL4030 */ #elif CONFIG_PMIC_TPS62350 /* do stuff specific to TPS62350 */ #elif CONFIG_PMIC_TPS65023 /* do stuff specific to TPS65023 */ #endif } /* ============================================================================= * * If we would like to run same image on multiple OMAP3EVMs and don't really * care about the image size, then we can follow the scheme below... * * Though there is still an open question of how to detect PMIC at runtime? * ============================================================================= */ /* * Definitions specific to TWL4030 */ /* * Definitions specific to TPS62350 */ /* * Definitions specific to TPS65023 */ static int flag_pmic_twl4030 = 0; static int flag_pmic_tps6235x = 0; static int flag_pmic_tps65023 = 0; /* * Detect the current PMIC * Set one of the flags */ static inline int detect_pmic() { /* How? Any suggestions?? */ } static inline int use_pmic_twl4030() { return flag_pmic_twl4030; } static inline int use_pmic_tps6235x() { return flag_pmic_tps6235x; } static inline int use_pmic_tps65023() { return flag_pmic_tps65023; } int omap3_evm_pmic_init() { if (use_pmic_twl4030()) { /* do stuff specific to TWL4030 */ } else if (use_pmic_tps6235x()) { /* do stuff specific to TPS62350 */ } else if (use_pmic_tps65023()) { /* do stuff specific to TPS65023 */ } } /* * * Generic wrappers to access PMIC registers and use its supported features... * */ int omap3_pmic_i2c_read() { /* Approach 1 */ #ifdef CONFIG_TWL4030_CORE /* do stuff specific to TWL4030 */ #elif CONFIG_PMIC_TPS62350 /* do stuff specific to TPS62350 */ #elif CONFIG_PMIC_TPS65023 /* do stuff specific to TPS65023 */ #endif /* Approach 2 */ if (use_pmic_twl4030()) { /* do stuff specific to TWL4030 */ } else if (use_pmic_tps6235x()) { /* do stuff specific to TPS62350 */ } else if (use_pmic_tps65023()) { /* do stuff specific to TPS65023 */ } } int omap3_pmic_i2c_write() { /* just for illustration */ } int omap3_evm_enable_lcd() { /* just for illustration */ } int omap3_evm_disable_lcd() { /* just for illustration */ } int omap3_evm_enable_dvi() { /* just for illustration */ } int omap3_evm_disable_dvi() { /* just for illustration */ } int omap3_evm_enable_tv() { /* just for illustration */ } int omap3_evm_disable_tv() { /* just for illustration */ }