diff options
author | Robby Cai <R63905@freescale.com> | 2011-04-02 17:46:58 +0800 |
---|---|---|
committer | Robby Cai <R63905@freescale.com> | 2011-05-08 22:18:55 -0500 |
commit | 2274205482a9e145c158cdb5c46c0b5da06fb65e (patch) | |
tree | 2932c0b94a0f64c549483fe5c2f2f4d5f79ff926 /include | |
parent | 6505e597f67aa5add30f318a1866507b9dbe282d (diff) |
ENGR00141508-1 MX50 RD3: Add PMIC Ripley driver
Support Regulator, ADC, TouchScreen, Battery, RTC.
PMIC issues are tracked on
http://wiki.freescale.net/display/MADPlatMX508/RD3+board+Issues+Tracking
Signed-off-by: Anson Huang <b20788@freescale.com>
Signed-off-by: Zhou Jingyu <Jingyu.Zhou@freescale.com>
Signed-off-by: Robby Cai <R63905@freescale.com>
(cherry picked from commit 12156df7104dba860d59b4f3729bad220cb33711)
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mfd/mc34708/core.h | 83 | ||||
-rw-r--r-- | include/linux/mfd/mc34708/mc34708.h | 134 | ||||
-rw-r--r-- | include/linux/mfd/mc34708/mc34708_adc.h | 88 | ||||
-rw-r--r-- | include/linux/mfd/mc34708/mc34708_battery.h | 162 | ||||
-rw-r--r-- | include/linux/pmic_external.h | 78 |
5 files changed, 543 insertions, 2 deletions
diff --git a/include/linux/mfd/mc34708/core.h b/include/linux/mfd/mc34708/core.h new file mode 100644 index 000000000000..9da55b6bbe75 --- /dev/null +++ b/include/linux/mfd/mc34708/core.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LINUX_MFD_MC34708_CORE_H_ +#define __LINUX_MFD_MC34708_CORE_H_ + +#include <linux/kernel.h> +#include <linux/mutex.h> +#include <linux/workqueue.h> +#include <linux/pmic_external.h> +/*! + * brief PMIC regulators. + */ +#define MC34708_SW1A 0 +#define MC34708_SW1B 1 +#define MC34708_SW2 2 +#define MC34708_SW3 3 +#define MC34708_SW4A 4 +#define MC34708_SW4B 5 +#define MC34708_SW5 6 +#define MC34708_SWBST 7 +#define MC34708_VPLL 8 +#define MC34708_VREFDDR 9 +#define MC34708_VUSB 10 +#define MC34708_VUSB2 11 +#define MC34708_VDAC 12 +#define MC34708_VGEN1 13 +#define MC34708_VGEN2 14 +#define MC34708_REG_NUM 15 + +struct mc34708; +struct regulator_init_data; + +struct mc34708_platform_data { + int (*init)(struct mc34708 *); + void *(*pmic_alloc_data)(struct device *dev); + int (*pmic_init_registers)(void); + void (*pmic_get_revision)(pmic_version_t *ver); +}; + +struct mc34708_pmic { + /* regulator devices */ + struct platform_device *pdev[MC34708_REG_NUM]; +}; + +struct mc34708 { + int rev; /* chip revision */ + + struct device *dev; + + /* device IO */ + union { + struct i2c_client *i2c_client; + struct spi_device *spi_device; + }; + u16 *reg_cache; + + /* Client devices */ + struct mc34708_pmic pmic; +}; + +int mc34708_register_regulator(struct mc34708 *mc34708, int reg, + struct regulator_init_data *initdata); +void *mc34708_alloc_data(struct device *dev); +int mc34708_init_registers(void); +void mc34708_get_revision(pmic_version_t *ver); + +#endif diff --git a/include/linux/mfd/mc34708/mc34708.h b/include/linux/mfd/mc34708/mc34708.h new file mode 100644 index 000000000000..cf56bfeb68ff --- /dev/null +++ b/include/linux/mfd/mc34708/mc34708.h @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ASM_ARCH_MXC_PMIC_MC34708_EXTERNAL_H__ +#define __ASM_ARCH_MXC_PMIC_MC34708_EXTERNAL_H__ + + +enum { + MC34708_REG_INT_STATUS0 = 0, + MC34708_REG_INT_MASK0, + MC34708_REG_INT_SENSE0, + MC34708_REG_INT_STATUS1, + MC34708_REG_INT_MASK1, + MC34708_REG_INT_SENSE1, + MC34708_REG_POWER_UP_MODE_SENSE, + MC34708_REG_IDENTIFICATION, + MC34708_REG_REGULATOR_FAULT_SENSE, + MC34708_REG_ACC0, + MC34708_REG_ACC1, + MC34708_REG_UNUSED0, + MC34708_REG_UNUSED1, + MC34708_REG_POWER_CTL0, + MC34708_REG_POWER_CTL1, + MC34708_REG_POWER_CTL2, + MC34708_REG_MEM_A, + MC34708_REG_MEM_B, + MC34708_REG_MEM_C, + MC34708_REG_MEM_D, + MC34708_REG_RTC_TIME, + MC34708_REG_RTC_ALARM, + MC34708_REG_RTC_DAY, + MC34708_REG_RTC_DAY_ALARM, + MC34708_REG_SW1AB, + MC34708_REG_SW2_3, + MC34708_REG_SW4AB, + MC34708_REG_SW5, + MC34708_REG_SW_OP_MODE_1_2, + MC34708_REG_SW_OP_MODE_3_4_5, + MC34708_REG_REGULATOR_SETTING0, + MC34708_REG_SWBST_CTL, + MC34708_REG_REGULATOR_MODE0, + MC34708_REG_GPIOLV0_CTL, + MC34708_REG_GPIOLV1_CTL, + MC34708_REG_GPIOLV2_CTL, + MC34708_REG_GPIOLV3_CTL, + MC34708_REG_USB_TIMING, + MC34708_REG_USB_BUTTON, + MC34708_REG_USB_CTL, + MC34708_REG_USB_DEVICE_TYPE, + MC34708_REG_UNUSED2, + MC34708_REG_UNUSED3, + MC34708_REG_ADC0, + MC34708_REG_ADC1, + MC34708_REG_ADC2, + MC34708_REG_ADC3, + MC34708_REG_ADC4, + MC34708_REG_ADC5, + MC34708_REG_ADC6, + MC34708_REG_ADC7, + MC34708_REG_BATTERY_PROFILE, + MC34708_REG_CHARGER_DEBOUNCE, + MC34708_REG_CHARGER_SOURCE, + MC34708_REG_CHARGER_LED_CTL, + MC34708_REG_PWM_CTL, + MC34708_REG_UNUSED4, + MC34708_REG_UNUSED5, + MC34708_REG_UNUSED6, + MC34708_REG_UNUSED7, + MC34708_REG_UNUSED8, + MC34708_REG_UNUSED9, + MC34708_REG_UNUSED10, + MC34708_REG_UNUSED11, +}; + +enum { + MC34708_EVENT_ADCDONEI = 0, + MC34708_EVENT_TSDONEI = 1, + MC34708_EVENT_TSPENDET = 2, + MC34708_EVENT_USBDET = 3, + MC34708_EVENT_AUXDET = 4, + MC34708_EVENT_USBOVP = 5, + MC34708_EVENT_AUXOVP = 6, + MC34708_EVENT_CHRTIMEEXP = 7, + MC34708_EVENT_BATTOTP = 8, + MC34708_EVENT_BATTOVP = 9, + MC34708_EVENT_CHRCMPL = 10, + MC34708_EVENT_WKVBUSDET = 11, + MC34708_EVENT_WKAUXDET = 12, + MC34708_EVENT_LOWBATT = 13, + MC34708_EVENT_VBUSREGMI = 14, + MC34708_EVENT_ATTACH = 15, + MC34708_EVENT_DETACH = 16, + MC34708_EVENT_KP = 17, + MC34708_EVENT_LKP = 18, + MC34708_EVENT_LKR = 19, + MC34708_EVENT_UKNOWN_ATTA = 20, + MC34708_EVENT_ADC_CHANGE = 21, + MC34708_EVENT_STUCK_KEY = 22, + MC34708_EVENT_STUCK_KEY_RCV = 23, + + MC34708_EVENT_1HZI = 24, + MC34708_EVENT_TODAI = 25, + MC34708_EVENT_Unused1 = 26, + MC34708_EVENT_PWRON1I = 27, + MC34708_EVENT_PWRON2I = 28, + MC34708_EVENT_WDIRESETI = 29, + MC34708_EVENT_SYSRSTI = 30, + MC34708_EVENT_RTCRSTI = 31, + MC34708_EVENT_PCI = 32, + MC34708_EVENT_WARMI = 33, + MC34708_EVENT_MEMHLDI = 34, + MC34708_EVENT_Unused2 = 35, + MC34708_EVENT_THWARNLI = 36, + MC34708_EVENT_THWARNHI = 37, + MC34708_EVENT_CLKI = 38, + MC34708_EVENT_Unused3 = 39, + MC34708_EVENT_SCPI = 40, +}; +#endif diff --git a/include/linux/mfd/mc34708/mc34708_adc.h b/include/linux/mfd/mc34708/mc34708_adc.h new file mode 100644 index 000000000000..721d7882ed10 --- /dev/null +++ b/include/linux/mfd/mc34708/mc34708_adc.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ASM_ARCH_MXC_MC34708_PMIC_ADC_H__ +#define __ASM_ARCH_MXC_MC34708_PMIC_ADC_H__ + +/*! + * @defgroup PMIC_ADC PMIC Digitizer Driver + * @ingroup PMIC_DRVRS + */ + +#include <linux/pmic_status.h> +#include <linux/pmic_external.h> + +/*! + * This enumeration defines input channels for PMIC ADC + */ + +typedef enum { + BATTERY_VOLTAGE, + BATTERY_CURRENT, + APPLICATION_SUPPLY_VOLTAGE, + DIE_TEMP, + AUX_CHARGER_VOLTAGE, + USB_VOLTAGE, + RESERVER0, + BATTERY_THEMISTOR, + COINCELL_VOLTAGE, + GEN_PURPOSE_AD9, + GEN_PURPOSE_AD10, + GEN_PURPOSE_AD11, + GEN_PURPOSE_AD12, + GEN_PURPOSE_AD13, + GEN_PURPOSE_AD14, + GEN_PURPOSE_AD15, +} t_channel; + + +/* EXPORTED FUNCTIONS */ + +#ifdef __KERNEL__ +/*! + * This function initializes all ADC registers with default values. This + * function also registers the interrupt events. + * + * @return This function returns PMIC_SUCCESS if successful. + */ +PMIC_STATUS mc34708_pmic_adc_init(void); + +/*! + * This function disables the ADC, de-registers the interrupt events. + * + * @return This function returns PMIC_SUCCESS if successful. + */ +PMIC_STATUS mc34708_pmic_adc_deinit(void); + +/*! + * This function triggers a conversion and returns one sampling result of one + * channel. + * + * @param channel The channel to be sampled + * @param result The pointer to the conversion result. The memory + * should be allocated by the caller of this function. + * + * @return This function returns PMIC_SUCCESS if successful. + */ + +PMIC_STATUS mc34708_pmic_adc_convert(t_channel channel, unsigned short *result); + + + +#endif /* _KERNEL */ +#endif /* __ASM_ARCH_MXC_PMIC_ADC_H__ */ diff --git a/include/linux/mfd/mc34708/mc34708_battery.h b/include/linux/mfd/mc34708/mc34708_battery.h new file mode 100644 index 000000000000..c38c4486a5e8 --- /dev/null +++ b/include/linux/mfd/mc34708/mc34708_battery.h @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _MC34708_BC_H +#define _MC34708_BC_H + +#include <linux/types.h> + +#define RIPLIEY_BC_MAX_RESTART_CYCLES 100 + +#define RIPLIEY_BC_LIION_CHARGING_VOLTAGE 4200 +#define RIPLIEY_BC_ALKALINE_NIMH_CHARGING_VOLTAGE 1750 + +/* brief Defines battery charger states. */ +typedef enum _ddi_bc_State { + /* brief TBD */ + RIPLIEY_BC_STATE_UNINITIALIZED = 0, + /* brief TBD */ + RIPLIEY_BC_STATE_BROKEN = 1, + /* brief TBD */ + RIPLIEY_BC_STATE_DISABLED = 2, + /* brief TBD */ + RIPLIEY_BC_STATE_WAITING_TO_CHARGE = 3, + /* brief TBD */ + RIPLIEY_BC_STATE_CONDITIONING = 4, + /* brief TBD */ + RIPLIEY_BC_STATE_CHARGING = 5, + /* brief TBD */ + RIPLIEY_BC_STATE_TOPPING_OFF = 6, + /* brief TBD */ + RIPLIEY_BC_STATE_DCDC_MODE_WAITING_TO_CHARGE = 7, + +} ddi_bc_State_t; + +typedef enum _ddi_bc_BrokenReason { + /* brief TBD */ + RIPLIEY_BC_BROKEN_UNINITIALIZED = 0, + /* brief TBD */ + RIPLIEY_BC_BROKEN_CHARGING_TIMEOUT = 1, + /* brief TBD */ + RIPLIEY_BC_BROKEN_FORCED_BY_APPLICATION = 2, + /* brief TBD */ + RIPLIEY_BC_BROKEN_EXTERNAL_BATTERY_VOLTAGE_DETECTED = 3, + /* brief TBD */ + RIPLIEY_BC_BROKEN_NO_BATTERY_DETECTED = 4, + +} ddi_bc_BrokenReason_t; + +struct mc34708_charger_setting_point { + u32 microVolt; + u32 microAmp; +}; + +/* brief Defines the battery charger configuration. */ +typedef struct mc34708_charger_config { + + u32 batteryTempLow; + u32 batteryTempHigh; + s32 hasTempSensor; + + u32 trickleThreshold; + + u32 vbusThresholdLow; + u32 vbusThresholdWeak; + u32 vbusThresholdHigh; + + u32 vauxThresholdLow; + u32 vauxThresholdWeak; + u32 vauxThresholdHigh; + + u32 lowBattThreshold; + + u32 toppingOffMicroAmp; + + struct mc34708_charger_setting_point *chargingPoints; + u32 pointsNumber; + +}; + +/* Status returned by Battery Charger functions. */ + +typedef enum _ddi_bc_Status { + /* brief TBD */ + RIPLIEY_BC_STATUS_SUCCESS = 0, + /* brief TBD */ + RIPLIEY_BC_STATUS_HARDWARE_DISABLED, + /* brief TBD */ + RIPLIEY_BC_STATUS_BAD_BATTERY_MODE, + /* brief TBD */ + RIPLIEY_BC_STATUS_CLOCK_GATE_CLOSED, + /* brief TBD */ + RIPLIEY_BC_STATUS_NOT_INITIALIZED, + /* brief TBD */ + RIPLIEY_BC_STATUS_ALREADY_INITIALIZED, + /* brief TBD */ + RIPLIEY_BC_STATUS_BROKEN, + /* brief TBD */ + RIPLIEY_BC_STATUS_NOT_BROKEN, + /* brief TBD */ + RIPLIEY_BC_STATUS_NOT_DISABLED, + /* brief TBD */ + RIPLIEY_BC_STATUS_BAD_ARGUMENT, + /* brief TBD */ + RIPLIEY_BC_STATUS_CFG_BAD_BATTERY_TEMP_CHANNEL, + /* brief TBD */ + RIPLIEY_BC_STATUS_CFG_BAD_CHARGING_VOLTAGE, +} ddi_bc_Status_t; + + +/* BCM Event Codes */ + +/* These are the codes that might be published to PMI Subscribers. */ + + +#define RIPLIEY_BC_EVENT_GROUP (11<<10) + +/* brief TBD */ +/* todo [PUBS] Add definition(s)... */ +typedef enum { + /* Use the error code group value to make events unique for the EOI */ + /* brief TBD */ + ddi_bc_MinEventCode = RIPLIEY_BC_EVENT_GROUP, + /* brief TBD */ + ddi_bc_WaitingToChargeCode, + /* brief TBD */ + ddi_bc_State_ConditioningCode, + /* brief TBD */ + ddi_bc_State_Topping_OffCode, + /* brief TBD */ + ddi_bc_State_BrokenCode, + /* brief TBD */ + ddi_bc_SettingChargeCode, + /* brief TBD */ + ddi_bc_RaisingDieTempAlarmCode, + /* brief TBD */ + ddi_bc_DroppingDieTempAlarmCode, + + /* brief TBD */ + ddi_bc_MaxEventCode, + /* brief TBD */ + ddi_bc_DcdcModeWaitingToChargeCode +} ddi_bc_Event_t; + + +/* End of file */ + +#endif /* _MC34708_BC_H */ diff --git a/include/linux/pmic_external.h b/include/linux/pmic_external.h index 0ea60e5abab2..cc66a33e1299 100644 --- a/include/linux/pmic_external.h +++ b/include/linux/pmic_external.h @@ -50,7 +50,8 @@ typedef enum { PMIC_MC13783 = 1, /*!< MC13783 */ PMIC_SC55112 = 2, /*!< SC55112 */ PMIC_MC13892 = 3, - PMIC_MC34704 = 4 + PMIC_MC34704 = 4, + PMIC_MC34708 = 5 } pmic_id_t; /*! @@ -132,7 +133,10 @@ typedef struct { #define PMIC_ARBITRATION "NULL" -#if defined(CONFIG_MXC_PMIC_MC13892_MODULE) || defined(CONFIG_MXC_PMIC_MC13892) +#if defined(CONFIG_MXC_PMIC_MC13892_MODULE) || \ + defined(CONFIG_MXC_PMIC_MC13892) || \ + defined(CONFIG_MXC_PMIC_MC34708_MODULE) || \ + defined(CONFIG_MXC_PMIC_MC34708) enum { REG_INT_STATUS0 = 0, REG_INT_MASK0, @@ -292,6 +296,76 @@ void gpio_pmic_active(void); void pmic_event_list_init(void); void mc13892_power_off(void); +enum { + REG_MC34708_INT_STATUS0 = 0, + REG_MC34708_INT_MASK0, + REG_MC34708_INT_SENSE0, + REG_MC34708_INT_STATUS1, + REG_MC34708_INT_MASK1, + REG_MC34708_INT_SENSE1, + REG_MC34708_PU_MODE_S, + REG_MC34708_IDENTIFICATION, + REG_MC34708_REGU_FAULT_S, + REG_MC34708_ACC0, + REG_MC34708_ACC1, /*10 */ + REG_MC34708_UNUSED1, + REG_MC34708_UNUSED2, + REG_MC34708_POWER_CTL0, + REG_MC34708_POWER_CTL1, + REG_MC34708_POWER_CTL2, + REG_MC34708_MEM_A, + REG_MC34708_MEM_B, + REG_MC34708_MEM_C, + REG_MC34708_MEM_D, + REG_MC34708_RTC_TIME, /*20 */ + REG_MC34708_RTC_ALARM, + REG_MC34708_RTC_DAY, + REG_MC34708_RTC_DAY_ALARM, + REG_MC34708_SW_1_A_B, + REG_MC34708_SW_2_3, + REG_MC34708_SW_4_A_B, + REG_MC34708_SW_5, + REG_MC34708_SW_1_2_OP, + REG_MC34708_SW_3_4_5_OP, + REG_MC34708_SETTING_0, /*30 */ + REG_MC34708_SWBST, + REG_MC34708_MODE_0, + REG_MC34708_GPIOLV0, + REG_MC34708_GPIOLV1, + REG_MC34708_GPIOLV2, + REG_MC34708_GPIOLV3, + REG_MC34708_USB_TIMING, + REG_MC34708_USB_BUTTON, + REG_MC34708_USB_CONTROL, + REG_MC34708_USB_DEVICE_TYPE, /*40 */ + REG_MC34708_UNUSED3, + REG_MC34708_UNUSED4, + REG_MC34708_ADC0, + REG_MC34708_ADC1, + REG_MC34708_ADC2, + REG_MC34708_ADC3, + REG_MC34708_ADC4, + REG_MC34708_ADC5, + REG_MC34708_ADC6, + REG_MC34708_ADC7, /*50 */ + REG_MC34708_BATTERY_PRO, + REG_MC34708_CHARGER_DEBOUNCE, + REG_MC34708_CHARGER_SOURCE, + REG_MC34708_CHARGER_LED_CON, + REG_MC34708_PWM_CON, + REG_MC34708_UNUSED5, + REG_MC34708_UNUSED6, + REG_MC34708_UNUSED7, + REG_MC34708_UNUSED8, + REG_MC34708_UNUSED9, /*60 */ + REG_MC34708_UNUSED10, + REG_MC34708_UNUSED11, + REG_MC34708_UNUSED12, +}; + +extern struct i2c_client *mc34708_client; +void mc34708_power_off(void); + #elif defined(CONFIG_MXC_PMIC_MC34704_MODULE) || defined(CONFIG_MXC_PMIC_MC34704) typedef enum { |