18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * twl4030.h - header for TWL4030 PM and audio CODEC device 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2005-2006 Texas Instruments, Inc. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Based on tlv320aic23.c: 88c2ecf20Sopenharmony_ci * Copyright (c) by Kai Svahn <kai.svahn@nokia.com> 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef __TWL_H_ 128c2ecf20Sopenharmony_ci#define __TWL_H_ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/types.h> 158c2ecf20Sopenharmony_ci#include <linux/input/matrix_keypad.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* 188c2ecf20Sopenharmony_ci * Using the twl4030 core we address registers using a pair 198c2ecf20Sopenharmony_ci * { module id, relative register offset } 208c2ecf20Sopenharmony_ci * which that core then maps to the relevant 218c2ecf20Sopenharmony_ci * { i2c slave, absolute register address } 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * The module IDs are meaningful only to the twl4030 core code, 248c2ecf20Sopenharmony_ci * which uses them as array indices to look up the first register 258c2ecf20Sopenharmony_ci * address each module uses within a given i2c slave. 268c2ecf20Sopenharmony_ci */ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* Module IDs for similar functionalities found in twl4030/twl6030 */ 298c2ecf20Sopenharmony_cienum twl_module_ids { 308c2ecf20Sopenharmony_ci TWL_MODULE_USB, 318c2ecf20Sopenharmony_ci TWL_MODULE_PIH, 328c2ecf20Sopenharmony_ci TWL_MODULE_MAIN_CHARGE, 338c2ecf20Sopenharmony_ci TWL_MODULE_PM_MASTER, 348c2ecf20Sopenharmony_ci TWL_MODULE_PM_RECEIVER, 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci TWL_MODULE_RTC, 378c2ecf20Sopenharmony_ci TWL_MODULE_PWM, 388c2ecf20Sopenharmony_ci TWL_MODULE_LED, 398c2ecf20Sopenharmony_ci TWL_MODULE_SECURED_REG, 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci TWL_MODULE_LAST, 428c2ecf20Sopenharmony_ci}; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* Modules only available in twl4030 series */ 458c2ecf20Sopenharmony_cienum twl4030_module_ids { 468c2ecf20Sopenharmony_ci TWL4030_MODULE_AUDIO_VOICE = TWL_MODULE_LAST, 478c2ecf20Sopenharmony_ci TWL4030_MODULE_GPIO, 488c2ecf20Sopenharmony_ci TWL4030_MODULE_INTBR, 498c2ecf20Sopenharmony_ci TWL4030_MODULE_TEST, 508c2ecf20Sopenharmony_ci TWL4030_MODULE_KEYPAD, 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci TWL4030_MODULE_MADC, 538c2ecf20Sopenharmony_ci TWL4030_MODULE_INTERRUPTS, 548c2ecf20Sopenharmony_ci TWL4030_MODULE_PRECHARGE, 558c2ecf20Sopenharmony_ci TWL4030_MODULE_BACKUP, 568c2ecf20Sopenharmony_ci TWL4030_MODULE_INT, 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci TWL5031_MODULE_ACCESSORY, 598c2ecf20Sopenharmony_ci TWL5031_MODULE_INTERRUPTS, 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci TWL4030_MODULE_LAST, 628c2ecf20Sopenharmony_ci}; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* Modules only available in twl6030 series */ 658c2ecf20Sopenharmony_cienum twl6030_module_ids { 668c2ecf20Sopenharmony_ci TWL6030_MODULE_ID0 = TWL_MODULE_LAST, 678c2ecf20Sopenharmony_ci TWL6030_MODULE_ID1, 688c2ecf20Sopenharmony_ci TWL6030_MODULE_ID2, 698c2ecf20Sopenharmony_ci TWL6030_MODULE_GPADC, 708c2ecf20Sopenharmony_ci TWL6030_MODULE_GASGAUGE, 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci TWL6030_MODULE_LAST, 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* Until the clients has been converted to use TWL_MODULE_LED */ 768c2ecf20Sopenharmony_ci#define TWL4030_MODULE_LED TWL_MODULE_LED 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define GPIO_INTR_OFFSET 0 798c2ecf20Sopenharmony_ci#define KEYPAD_INTR_OFFSET 1 808c2ecf20Sopenharmony_ci#define BCI_INTR_OFFSET 2 818c2ecf20Sopenharmony_ci#define MADC_INTR_OFFSET 3 828c2ecf20Sopenharmony_ci#define USB_INTR_OFFSET 4 838c2ecf20Sopenharmony_ci#define CHARGERFAULT_INTR_OFFSET 5 848c2ecf20Sopenharmony_ci#define BCI_PRES_INTR_OFFSET 9 858c2ecf20Sopenharmony_ci#define USB_PRES_INTR_OFFSET 10 868c2ecf20Sopenharmony_ci#define RTC_INTR_OFFSET 11 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* 898c2ecf20Sopenharmony_ci * Offset from TWL6030_IRQ_BASE / pdata->irq_base 908c2ecf20Sopenharmony_ci */ 918c2ecf20Sopenharmony_ci#define PWR_INTR_OFFSET 0 928c2ecf20Sopenharmony_ci#define HOTDIE_INTR_OFFSET 12 938c2ecf20Sopenharmony_ci#define SMPSLDO_INTR_OFFSET 13 948c2ecf20Sopenharmony_ci#define BATDETECT_INTR_OFFSET 14 958c2ecf20Sopenharmony_ci#define SIMDETECT_INTR_OFFSET 15 968c2ecf20Sopenharmony_ci#define MMCDETECT_INTR_OFFSET 16 978c2ecf20Sopenharmony_ci#define GASGAUGE_INTR_OFFSET 17 988c2ecf20Sopenharmony_ci#define USBOTG_INTR_OFFSET 4 998c2ecf20Sopenharmony_ci#define CHARGER_INTR_OFFSET 2 1008c2ecf20Sopenharmony_ci#define RSV_INTR_OFFSET 0 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci/* INT register offsets */ 1038c2ecf20Sopenharmony_ci#define REG_INT_STS_A 0x00 1048c2ecf20Sopenharmony_ci#define REG_INT_STS_B 0x01 1058c2ecf20Sopenharmony_ci#define REG_INT_STS_C 0x02 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#define REG_INT_MSK_LINE_A 0x03 1088c2ecf20Sopenharmony_ci#define REG_INT_MSK_LINE_B 0x04 1098c2ecf20Sopenharmony_ci#define REG_INT_MSK_LINE_C 0x05 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define REG_INT_MSK_STS_A 0x06 1128c2ecf20Sopenharmony_ci#define REG_INT_MSK_STS_B 0x07 1138c2ecf20Sopenharmony_ci#define REG_INT_MSK_STS_C 0x08 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/* MASK INT REG GROUP A */ 1168c2ecf20Sopenharmony_ci#define TWL6030_PWR_INT_MASK 0x07 1178c2ecf20Sopenharmony_ci#define TWL6030_RTC_INT_MASK 0x18 1188c2ecf20Sopenharmony_ci#define TWL6030_HOTDIE_INT_MASK 0x20 1198c2ecf20Sopenharmony_ci#define TWL6030_SMPSLDOA_INT_MASK 0xC0 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci/* MASK INT REG GROUP B */ 1228c2ecf20Sopenharmony_ci#define TWL6030_SMPSLDOB_INT_MASK 0x01 1238c2ecf20Sopenharmony_ci#define TWL6030_BATDETECT_INT_MASK 0x02 1248c2ecf20Sopenharmony_ci#define TWL6030_SIMDETECT_INT_MASK 0x04 1258c2ecf20Sopenharmony_ci#define TWL6030_MMCDETECT_INT_MASK 0x08 1268c2ecf20Sopenharmony_ci#define TWL6030_GPADC_INT_MASK 0x60 1278c2ecf20Sopenharmony_ci#define TWL6030_GASGAUGE_INT_MASK 0x80 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci/* MASK INT REG GROUP C */ 1308c2ecf20Sopenharmony_ci#define TWL6030_USBOTG_INT_MASK 0x0F 1318c2ecf20Sopenharmony_ci#define TWL6030_CHARGER_CTRL_INT_MASK 0x10 1328c2ecf20Sopenharmony_ci#define TWL6030_CHARGER_FAULT_INT_MASK 0x60 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define TWL6030_MMCCTRL 0xEE 1358c2ecf20Sopenharmony_ci#define VMMC_AUTO_OFF (0x1 << 3) 1368c2ecf20Sopenharmony_ci#define SW_FC (0x1 << 2) 1378c2ecf20Sopenharmony_ci#define STS_MMC 0x1 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci#define TWL6030_CFG_INPUT_PUPD3 0xF2 1408c2ecf20Sopenharmony_ci#define MMC_PU (0x1 << 3) 1418c2ecf20Sopenharmony_ci#define MMC_PD (0x1 << 2) 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#define TWL_SIL_TYPE(rev) ((rev) & 0x00FFFFFF) 1448c2ecf20Sopenharmony_ci#define TWL_SIL_REV(rev) ((rev) >> 24) 1458c2ecf20Sopenharmony_ci#define TWL_SIL_5030 0x09002F 1468c2ecf20Sopenharmony_ci#define TWL5030_REV_1_0 0x00 1478c2ecf20Sopenharmony_ci#define TWL5030_REV_1_1 0x10 1488c2ecf20Sopenharmony_ci#define TWL5030_REV_1_2 0x30 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci#define TWL4030_CLASS_ID 0x4030 1518c2ecf20Sopenharmony_ci#define TWL6030_CLASS_ID 0x6030 1528c2ecf20Sopenharmony_ciunsigned int twl_rev(void); 1538c2ecf20Sopenharmony_ci#define GET_TWL_REV (twl_rev()) 1548c2ecf20Sopenharmony_ci#define TWL_CLASS_IS(class, id) \ 1558c2ecf20Sopenharmony_cistatic inline int twl_class_is_ ##class(void) \ 1568c2ecf20Sopenharmony_ci{ \ 1578c2ecf20Sopenharmony_ci return ((id) == (GET_TWL_REV)) ? 1 : 0; \ 1588c2ecf20Sopenharmony_ci} 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ciTWL_CLASS_IS(4030, TWL4030_CLASS_ID) 1618c2ecf20Sopenharmony_ciTWL_CLASS_IS(6030, TWL6030_CLASS_ID) 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci/* Set the regcache bypass for the regmap associated with the nodule */ 1648c2ecf20Sopenharmony_ciint twl_set_regcache_bypass(u8 mod_no, bool enable); 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci/* 1678c2ecf20Sopenharmony_ci * Read and write several 8-bit registers at once. 1688c2ecf20Sopenharmony_ci */ 1698c2ecf20Sopenharmony_ciint twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); 1708c2ecf20Sopenharmony_ciint twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes); 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci/* 1738c2ecf20Sopenharmony_ci * Read and write single 8-bit registers 1748c2ecf20Sopenharmony_ci */ 1758c2ecf20Sopenharmony_cistatic inline int twl_i2c_write_u8(u8 mod_no, u8 val, u8 reg) { 1768c2ecf20Sopenharmony_ci return twl_i2c_write(mod_no, &val, reg, 1); 1778c2ecf20Sopenharmony_ci} 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_cistatic inline int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg) { 1808c2ecf20Sopenharmony_ci return twl_i2c_read(mod_no, val, reg, 1); 1818c2ecf20Sopenharmony_ci} 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_cistatic inline int twl_i2c_write_u16(u8 mod_no, u16 val, u8 reg) { 1848c2ecf20Sopenharmony_ci __le16 value; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci value = cpu_to_le16(val); 1878c2ecf20Sopenharmony_ci return twl_i2c_write(mod_no, (u8 *) &value, reg, 2); 1888c2ecf20Sopenharmony_ci} 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_cistatic inline int twl_i2c_read_u16(u8 mod_no, u16 *val, u8 reg) { 1918c2ecf20Sopenharmony_ci int ret; 1928c2ecf20Sopenharmony_ci __le16 value; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci ret = twl_i2c_read(mod_no, (u8 *) &value, reg, 2); 1958c2ecf20Sopenharmony_ci *val = le16_to_cpu(value); 1968c2ecf20Sopenharmony_ci return ret; 1978c2ecf20Sopenharmony_ci} 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ciint twl_get_type(void); 2008c2ecf20Sopenharmony_ciint twl_get_version(void); 2018c2ecf20Sopenharmony_ciint twl_get_hfclk_rate(void); 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ciint twl6030_interrupt_unmask(u8 bit_mask, u8 offset); 2048c2ecf20Sopenharmony_ciint twl6030_interrupt_mask(u8 bit_mask, u8 offset); 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci/* Card detect Configuration for MMC1 Controller on OMAP4 */ 2078c2ecf20Sopenharmony_ci#ifdef CONFIG_TWL4030_CORE 2088c2ecf20Sopenharmony_ciint twl6030_mmc_card_detect_config(void); 2098c2ecf20Sopenharmony_ci#else 2108c2ecf20Sopenharmony_cistatic inline int twl6030_mmc_card_detect_config(void) 2118c2ecf20Sopenharmony_ci{ 2128c2ecf20Sopenharmony_ci pr_debug("twl6030_mmc_card_detect_config not supported\n"); 2138c2ecf20Sopenharmony_ci return 0; 2148c2ecf20Sopenharmony_ci} 2158c2ecf20Sopenharmony_ci#endif 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci/* MMC1 Controller on OMAP4 uses Phoenix irq for Card detect */ 2188c2ecf20Sopenharmony_ci#ifdef CONFIG_TWL4030_CORE 2198c2ecf20Sopenharmony_ciint twl6030_mmc_card_detect(struct device *dev, int slot); 2208c2ecf20Sopenharmony_ci#else 2218c2ecf20Sopenharmony_cistatic inline int twl6030_mmc_card_detect(struct device *dev, int slot) 2228c2ecf20Sopenharmony_ci{ 2238c2ecf20Sopenharmony_ci pr_debug("Call back twl6030_mmc_card_detect not supported\n"); 2248c2ecf20Sopenharmony_ci return -EIO; 2258c2ecf20Sopenharmony_ci} 2268c2ecf20Sopenharmony_ci#endif 2278c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci/* 2308c2ecf20Sopenharmony_ci * NOTE: at up to 1024 registers, this is a big chip. 2318c2ecf20Sopenharmony_ci * 2328c2ecf20Sopenharmony_ci * Avoid putting register declarations in this file, instead of into 2338c2ecf20Sopenharmony_ci * a driver-private file, unless some of the registers in a block 2348c2ecf20Sopenharmony_ci * need to be shared with other drivers. One example is blocks that 2358c2ecf20Sopenharmony_ci * have Secondary IRQ Handler (SIH) registers. 2368c2ecf20Sopenharmony_ci */ 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci#define TWL4030_SIH_CTRL_EXCLEN_MASK BIT(0) 2398c2ecf20Sopenharmony_ci#define TWL4030_SIH_CTRL_PENDDIS_MASK BIT(1) 2408c2ecf20Sopenharmony_ci#define TWL4030_SIH_CTRL_COR_MASK BIT(2) 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci/* 2458c2ecf20Sopenharmony_ci * GPIO Block Register offsets (use TWL4030_MODULE_GPIO) 2468c2ecf20Sopenharmony_ci */ 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci#define REG_GPIODATAIN1 0x0 2498c2ecf20Sopenharmony_ci#define REG_GPIODATAIN2 0x1 2508c2ecf20Sopenharmony_ci#define REG_GPIODATAIN3 0x2 2518c2ecf20Sopenharmony_ci#define REG_GPIODATADIR1 0x3 2528c2ecf20Sopenharmony_ci#define REG_GPIODATADIR2 0x4 2538c2ecf20Sopenharmony_ci#define REG_GPIODATADIR3 0x5 2548c2ecf20Sopenharmony_ci#define REG_GPIODATAOUT1 0x6 2558c2ecf20Sopenharmony_ci#define REG_GPIODATAOUT2 0x7 2568c2ecf20Sopenharmony_ci#define REG_GPIODATAOUT3 0x8 2578c2ecf20Sopenharmony_ci#define REG_CLEARGPIODATAOUT1 0x9 2588c2ecf20Sopenharmony_ci#define REG_CLEARGPIODATAOUT2 0xA 2598c2ecf20Sopenharmony_ci#define REG_CLEARGPIODATAOUT3 0xB 2608c2ecf20Sopenharmony_ci#define REG_SETGPIODATAOUT1 0xC 2618c2ecf20Sopenharmony_ci#define REG_SETGPIODATAOUT2 0xD 2628c2ecf20Sopenharmony_ci#define REG_SETGPIODATAOUT3 0xE 2638c2ecf20Sopenharmony_ci#define REG_GPIO_DEBEN1 0xF 2648c2ecf20Sopenharmony_ci#define REG_GPIO_DEBEN2 0x10 2658c2ecf20Sopenharmony_ci#define REG_GPIO_DEBEN3 0x11 2668c2ecf20Sopenharmony_ci#define REG_GPIO_CTRL 0x12 2678c2ecf20Sopenharmony_ci#define REG_GPIOPUPDCTR1 0x13 2688c2ecf20Sopenharmony_ci#define REG_GPIOPUPDCTR2 0x14 2698c2ecf20Sopenharmony_ci#define REG_GPIOPUPDCTR3 0x15 2708c2ecf20Sopenharmony_ci#define REG_GPIOPUPDCTR4 0x16 2718c2ecf20Sopenharmony_ci#define REG_GPIOPUPDCTR5 0x17 2728c2ecf20Sopenharmony_ci#define REG_GPIO_ISR1A 0x19 2738c2ecf20Sopenharmony_ci#define REG_GPIO_ISR2A 0x1A 2748c2ecf20Sopenharmony_ci#define REG_GPIO_ISR3A 0x1B 2758c2ecf20Sopenharmony_ci#define REG_GPIO_IMR1A 0x1C 2768c2ecf20Sopenharmony_ci#define REG_GPIO_IMR2A 0x1D 2778c2ecf20Sopenharmony_ci#define REG_GPIO_IMR3A 0x1E 2788c2ecf20Sopenharmony_ci#define REG_GPIO_ISR1B 0x1F 2798c2ecf20Sopenharmony_ci#define REG_GPIO_ISR2B 0x20 2808c2ecf20Sopenharmony_ci#define REG_GPIO_ISR3B 0x21 2818c2ecf20Sopenharmony_ci#define REG_GPIO_IMR1B 0x22 2828c2ecf20Sopenharmony_ci#define REG_GPIO_IMR2B 0x23 2838c2ecf20Sopenharmony_ci#define REG_GPIO_IMR3B 0x24 2848c2ecf20Sopenharmony_ci#define REG_GPIO_EDR1 0x28 2858c2ecf20Sopenharmony_ci#define REG_GPIO_EDR2 0x29 2868c2ecf20Sopenharmony_ci#define REG_GPIO_EDR3 0x2A 2878c2ecf20Sopenharmony_ci#define REG_GPIO_EDR4 0x2B 2888c2ecf20Sopenharmony_ci#define REG_GPIO_EDR5 0x2C 2898c2ecf20Sopenharmony_ci#define REG_GPIO_SIH_CTRL 0x2D 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci/* Up to 18 signals are available as GPIOs, when their 2928c2ecf20Sopenharmony_ci * pins are not assigned to another use (such as ULPI/USB). 2938c2ecf20Sopenharmony_ci */ 2948c2ecf20Sopenharmony_ci#define TWL4030_GPIO_MAX 18 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci/*Interface Bit Register (INTBR) offsets 2998c2ecf20Sopenharmony_ci *(Use TWL_4030_MODULE_INTBR) 3008c2ecf20Sopenharmony_ci */ 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci#define REG_IDCODE_7_0 0x00 3038c2ecf20Sopenharmony_ci#define REG_IDCODE_15_8 0x01 3048c2ecf20Sopenharmony_ci#define REG_IDCODE_16_23 0x02 3058c2ecf20Sopenharmony_ci#define REG_IDCODE_31_24 0x03 3068c2ecf20Sopenharmony_ci#define REG_GPPUPDCTR1 0x0F 3078c2ecf20Sopenharmony_ci#define REG_UNLOCK_TEST_REG 0x12 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci/*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */ 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci#define I2C_SCL_CTRL_PU BIT(0) 3128c2ecf20Sopenharmony_ci#define I2C_SDA_CTRL_PU BIT(2) 3138c2ecf20Sopenharmony_ci#define SR_I2C_SCL_CTRL_PU BIT(4) 3148c2ecf20Sopenharmony_ci#define SR_I2C_SDA_CTRL_PU BIT(6) 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci#define TWL_EEPROM_R_UNLOCK 0x49 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci/* 3218c2ecf20Sopenharmony_ci * Keypad register offsets (use TWL4030_MODULE_KEYPAD) 3228c2ecf20Sopenharmony_ci * ... SIH/interrupt only 3238c2ecf20Sopenharmony_ci */ 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci#define TWL4030_KEYPAD_KEYP_ISR1 0x11 3268c2ecf20Sopenharmony_ci#define TWL4030_KEYPAD_KEYP_IMR1 0x12 3278c2ecf20Sopenharmony_ci#define TWL4030_KEYPAD_KEYP_ISR2 0x13 3288c2ecf20Sopenharmony_ci#define TWL4030_KEYPAD_KEYP_IMR2 0x14 3298c2ecf20Sopenharmony_ci#define TWL4030_KEYPAD_KEYP_SIR 0x15 /* test register */ 3308c2ecf20Sopenharmony_ci#define TWL4030_KEYPAD_KEYP_EDR 0x16 3318c2ecf20Sopenharmony_ci#define TWL4030_KEYPAD_KEYP_SIH_CTRL 0x17 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci/* 3368c2ecf20Sopenharmony_ci * Multichannel ADC register offsets (use TWL4030_MODULE_MADC) 3378c2ecf20Sopenharmony_ci * ... SIH/interrupt only 3388c2ecf20Sopenharmony_ci */ 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci#define TWL4030_MADC_ISR1 0x61 3418c2ecf20Sopenharmony_ci#define TWL4030_MADC_IMR1 0x62 3428c2ecf20Sopenharmony_ci#define TWL4030_MADC_ISR2 0x63 3438c2ecf20Sopenharmony_ci#define TWL4030_MADC_IMR2 0x64 3448c2ecf20Sopenharmony_ci#define TWL4030_MADC_SIR 0x65 /* test register */ 3458c2ecf20Sopenharmony_ci#define TWL4030_MADC_EDR 0x66 3468c2ecf20Sopenharmony_ci#define TWL4030_MADC_SIH_CTRL 0x67 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ci/* 3518c2ecf20Sopenharmony_ci * Battery charger register offsets (use TWL4030_MODULE_INTERRUPTS) 3528c2ecf20Sopenharmony_ci */ 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIISR1A 0x0 3558c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIISR2A 0x1 3568c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIIMR1A 0x2 3578c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIIMR2A 0x3 3588c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIISR1B 0x4 3598c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIISR2B 0x5 3608c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIIMR1B 0x6 3618c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIIMR2B 0x7 3628c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCISIR1 0x8 /* test register */ 3638c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCISIR2 0x9 /* test register */ 3648c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIEDR1 0xa 3658c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIEDR2 0xb 3668c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCIEDR3 0xc 3678c2ecf20Sopenharmony_ci#define TWL4030_INTERRUPTS_BCISIHCTRL 0xd 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci/* 3728c2ecf20Sopenharmony_ci * Power Interrupt block register offsets (use TWL4030_MODULE_INT) 3738c2ecf20Sopenharmony_ci */ 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci#define TWL4030_INT_PWR_ISR1 0x0 3768c2ecf20Sopenharmony_ci#define TWL4030_INT_PWR_IMR1 0x1 3778c2ecf20Sopenharmony_ci#define TWL4030_INT_PWR_ISR2 0x2 3788c2ecf20Sopenharmony_ci#define TWL4030_INT_PWR_IMR2 0x3 3798c2ecf20Sopenharmony_ci#define TWL4030_INT_PWR_SIR 0x4 /* test register */ 3808c2ecf20Sopenharmony_ci#define TWL4030_INT_PWR_EDR1 0x5 3818c2ecf20Sopenharmony_ci#define TWL4030_INT_PWR_EDR2 0x6 3828c2ecf20Sopenharmony_ci#define TWL4030_INT_PWR_SIH_CTRL 0x7 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_ci/* 3878c2ecf20Sopenharmony_ci * Accessory Interrupts 3888c2ecf20Sopenharmony_ci */ 3898c2ecf20Sopenharmony_ci#define TWL5031_ACIIMR_LSB 0x05 3908c2ecf20Sopenharmony_ci#define TWL5031_ACIIMR_MSB 0x06 3918c2ecf20Sopenharmony_ci#define TWL5031_ACIIDR_LSB 0x07 3928c2ecf20Sopenharmony_ci#define TWL5031_ACIIDR_MSB 0x08 3938c2ecf20Sopenharmony_ci#define TWL5031_ACCISR1 0x0F 3948c2ecf20Sopenharmony_ci#define TWL5031_ACCIMR1 0x10 3958c2ecf20Sopenharmony_ci#define TWL5031_ACCISR2 0x11 3968c2ecf20Sopenharmony_ci#define TWL5031_ACCIMR2 0x12 3978c2ecf20Sopenharmony_ci#define TWL5031_ACCSIR 0x13 3988c2ecf20Sopenharmony_ci#define TWL5031_ACCEDR1 0x14 3998c2ecf20Sopenharmony_ci#define TWL5031_ACCSIHCTRL 0x15 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ci/* 4048c2ecf20Sopenharmony_ci * Battery Charger Controller 4058c2ecf20Sopenharmony_ci */ 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci#define TWL5031_INTERRUPTS_BCIISR1 0x0 4088c2ecf20Sopenharmony_ci#define TWL5031_INTERRUPTS_BCIIMR1 0x1 4098c2ecf20Sopenharmony_ci#define TWL5031_INTERRUPTS_BCIISR2 0x2 4108c2ecf20Sopenharmony_ci#define TWL5031_INTERRUPTS_BCIIMR2 0x3 4118c2ecf20Sopenharmony_ci#define TWL5031_INTERRUPTS_BCISIR 0x4 4128c2ecf20Sopenharmony_ci#define TWL5031_INTERRUPTS_BCIEDR1 0x5 4138c2ecf20Sopenharmony_ci#define TWL5031_INTERRUPTS_BCIEDR2 0x6 4148c2ecf20Sopenharmony_ci#define TWL5031_INTERRUPTS_BCISIHCTRL 0x7 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci/* 4198c2ecf20Sopenharmony_ci * PM Master module register offsets (use TWL4030_MODULE_PM_MASTER) 4208c2ecf20Sopenharmony_ci */ 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_CFG_P1_TRANSITION 0x00 4238c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_CFG_P2_TRANSITION 0x01 4248c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_CFG_P3_TRANSITION 0x02 4258c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_CFG_P123_TRANSITION 0x03 4268c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_STS_BOOT 0x04 4278c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_CFG_BOOT 0x05 4288c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_SHUNDAN 0x06 4298c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_BOOT_BCI 0x07 4308c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_CFG_PWRANA1 0x08 4318c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_CFG_PWRANA2 0x09 4328c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_BACKUP_MISC_STS 0x0b 4338c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_BACKUP_MISC_CFG 0x0c 4348c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_BACKUP_MISC_TST 0x0d 4358c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_PROTECT_KEY 0x0e 4368c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_STS_HW_CONDITIONS 0x0f 4378c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_P1_SW_EVENTS 0x10 4388c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_P2_SW_EVENTS 0x11 4398c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_P3_SW_EVENTS 0x12 4408c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_STS_P123_STATE 0x13 4418c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_PB_CFG 0x14 4428c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_PB_WORD_MSB 0x15 4438c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_PB_WORD_LSB 0x16 4448c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_SEQ_ADD_W2P 0x1c 4458c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_SEQ_ADD_P2A 0x1d 4468c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_SEQ_ADD_A2W 0x1e 4478c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_SEQ_ADD_A2S 0x1f 4488c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_SEQ_ADD_S2A12 0x20 4498c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_SEQ_ADD_S2A3 0x21 4508c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_SEQ_ADD_WARM 0x22 4518c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_MEMORY_ADDRESS 0x23 4528c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_MEMORY_DATA 0x24 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_KEY_CFG1 0xc0 4558c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_KEY_CFG2 0x0c 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_KEY_TST1 0xe0 4588c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_KEY_TST2 0x0e 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_ci#define TWL4030_PM_MASTER_GLOBAL_TST 0xb6 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci/* Power bus message definitions */ 4658c2ecf20Sopenharmony_ci 4668c2ecf20Sopenharmony_ci/* The TWL4030/5030 splits its power-management resources (the various 4678c2ecf20Sopenharmony_ci * regulators, clock and reset lines) into 3 processor groups - P1, P2 and 4688c2ecf20Sopenharmony_ci * P3. These groups can then be configured to transition between sleep, wait-on 4698c2ecf20Sopenharmony_ci * and active states by sending messages to the power bus. See Section 5.4.2 4708c2ecf20Sopenharmony_ci * Power Resources of TWL4030 TRM 4718c2ecf20Sopenharmony_ci */ 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ci/* Processor groups */ 4748c2ecf20Sopenharmony_ci#define DEV_GRP_NULL 0x0 4758c2ecf20Sopenharmony_ci#define DEV_GRP_P1 0x1 /* P1: all OMAP devices */ 4768c2ecf20Sopenharmony_ci#define DEV_GRP_P2 0x2 /* P2: all Modem devices */ 4778c2ecf20Sopenharmony_ci#define DEV_GRP_P3 0x4 /* P3: all peripheral devices */ 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci/* Resource groups */ 4808c2ecf20Sopenharmony_ci#define RES_GRP_RES 0x0 /* Reserved */ 4818c2ecf20Sopenharmony_ci#define RES_GRP_PP 0x1 /* Power providers */ 4828c2ecf20Sopenharmony_ci#define RES_GRP_RC 0x2 /* Reset and control */ 4838c2ecf20Sopenharmony_ci#define RES_GRP_PP_RC 0x3 4848c2ecf20Sopenharmony_ci#define RES_GRP_PR 0x4 /* Power references */ 4858c2ecf20Sopenharmony_ci#define RES_GRP_PP_PR 0x5 4868c2ecf20Sopenharmony_ci#define RES_GRP_RC_PR 0x6 4878c2ecf20Sopenharmony_ci#define RES_GRP_ALL 0x7 /* All resource groups */ 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_ci#define RES_TYPE2_R0 0x0 4908c2ecf20Sopenharmony_ci#define RES_TYPE2_R1 0x1 4918c2ecf20Sopenharmony_ci#define RES_TYPE2_R2 0x2 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_ci#define RES_TYPE_R0 0x0 4948c2ecf20Sopenharmony_ci#define RES_TYPE_ALL 0x7 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci/* Resource states */ 4978c2ecf20Sopenharmony_ci#define RES_STATE_WRST 0xF 4988c2ecf20Sopenharmony_ci#define RES_STATE_ACTIVE 0xE 4998c2ecf20Sopenharmony_ci#define RES_STATE_SLEEP 0x8 5008c2ecf20Sopenharmony_ci#define RES_STATE_OFF 0x0 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci/* Power resources */ 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci/* Power providers */ 5058c2ecf20Sopenharmony_ci#define RES_VAUX1 1 5068c2ecf20Sopenharmony_ci#define RES_VAUX2 2 5078c2ecf20Sopenharmony_ci#define RES_VAUX3 3 5088c2ecf20Sopenharmony_ci#define RES_VAUX4 4 5098c2ecf20Sopenharmony_ci#define RES_VMMC1 5 5108c2ecf20Sopenharmony_ci#define RES_VMMC2 6 5118c2ecf20Sopenharmony_ci#define RES_VPLL1 7 5128c2ecf20Sopenharmony_ci#define RES_VPLL2 8 5138c2ecf20Sopenharmony_ci#define RES_VSIM 9 5148c2ecf20Sopenharmony_ci#define RES_VDAC 10 5158c2ecf20Sopenharmony_ci#define RES_VINTANA1 11 5168c2ecf20Sopenharmony_ci#define RES_VINTANA2 12 5178c2ecf20Sopenharmony_ci#define RES_VINTDIG 13 5188c2ecf20Sopenharmony_ci#define RES_VIO 14 5198c2ecf20Sopenharmony_ci#define RES_VDD1 15 5208c2ecf20Sopenharmony_ci#define RES_VDD2 16 5218c2ecf20Sopenharmony_ci#define RES_VUSB_1V5 17 5228c2ecf20Sopenharmony_ci#define RES_VUSB_1V8 18 5238c2ecf20Sopenharmony_ci#define RES_VUSB_3V1 19 5248c2ecf20Sopenharmony_ci#define RES_VUSBCP 20 5258c2ecf20Sopenharmony_ci#define RES_REGEN 21 5268c2ecf20Sopenharmony_ci/* Reset and control */ 5278c2ecf20Sopenharmony_ci#define RES_NRES_PWRON 22 5288c2ecf20Sopenharmony_ci#define RES_CLKEN 23 5298c2ecf20Sopenharmony_ci#define RES_SYSEN 24 5308c2ecf20Sopenharmony_ci#define RES_HFCLKOUT 25 5318c2ecf20Sopenharmony_ci#define RES_32KCLKOUT 26 5328c2ecf20Sopenharmony_ci#define RES_RESET 27 5338c2ecf20Sopenharmony_ci/* Power Reference */ 5348c2ecf20Sopenharmony_ci#define RES_MAIN_REF 28 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci#define TOTAL_RESOURCES 28 5378c2ecf20Sopenharmony_ci/* 5388c2ecf20Sopenharmony_ci * Power Bus Message Format ... these can be sent individually by Linux, 5398c2ecf20Sopenharmony_ci * but are usually part of downloaded scripts that are run when various 5408c2ecf20Sopenharmony_ci * power events are triggered. 5418c2ecf20Sopenharmony_ci * 5428c2ecf20Sopenharmony_ci * Broadcast Message (16 Bits): 5438c2ecf20Sopenharmony_ci * DEV_GRP[15:13] MT[12] RES_GRP[11:9] RES_TYPE2[8:7] RES_TYPE[6:4] 5448c2ecf20Sopenharmony_ci * RES_STATE[3:0] 5458c2ecf20Sopenharmony_ci * 5468c2ecf20Sopenharmony_ci * Singular Message (16 Bits): 5478c2ecf20Sopenharmony_ci * DEV_GRP[15:13] MT[12] RES_ID[11:4] RES_STATE[3:0] 5488c2ecf20Sopenharmony_ci */ 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ci#define MSG_BROADCAST(devgrp, grp, type, type2, state) \ 5518c2ecf20Sopenharmony_ci ( (devgrp) << 13 | 1 << 12 | (grp) << 9 | (type2) << 7 \ 5528c2ecf20Sopenharmony_ci | (type) << 4 | (state)) 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_ci#define MSG_SINGULAR(devgrp, id, state) \ 5558c2ecf20Sopenharmony_ci ((devgrp) << 13 | 0 << 12 | (id) << 4 | (state)) 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ci#define MSG_BROADCAST_ALL(devgrp, state) \ 5588c2ecf20Sopenharmony_ci ((devgrp) << 5 | (state)) 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci#define MSG_BROADCAST_REF MSG_BROADCAST_ALL 5618c2ecf20Sopenharmony_ci#define MSG_BROADCAST_PROV MSG_BROADCAST_ALL 5628c2ecf20Sopenharmony_ci#define MSG_BROADCAST__CLK_RST MSG_BROADCAST_ALL 5638c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 5648c2ecf20Sopenharmony_ci 5658c2ecf20Sopenharmony_cistruct twl4030_clock_init_data { 5668c2ecf20Sopenharmony_ci bool ck32k_lowpwr_enable; 5678c2ecf20Sopenharmony_ci}; 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_cistruct twl4030_bci_platform_data { 5708c2ecf20Sopenharmony_ci int *battery_tmp_tbl; 5718c2ecf20Sopenharmony_ci unsigned int tblsize; 5728c2ecf20Sopenharmony_ci int bb_uvolt; /* voltage to charge backup battery */ 5738c2ecf20Sopenharmony_ci int bb_uamp; /* current for backup battery charging */ 5748c2ecf20Sopenharmony_ci}; 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_ci/* TWL4030_GPIO_MAX (18) GPIOs, with interrupts */ 5778c2ecf20Sopenharmony_cistruct twl4030_gpio_platform_data { 5788c2ecf20Sopenharmony_ci /* package the two LED signals as output-only GPIOs? */ 5798c2ecf20Sopenharmony_ci bool use_leds; 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci /* gpio-n should control VMMC(n+1) if BIT(n) in mmc_cd is set */ 5828c2ecf20Sopenharmony_ci u8 mmc_cd; 5838c2ecf20Sopenharmony_ci 5848c2ecf20Sopenharmony_ci /* if BIT(N) is set, or VMMC(n+1) is linked, debounce GPIO-N */ 5858c2ecf20Sopenharmony_ci u32 debounce; 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_ci /* For gpio-N, bit (1 << N) in "pullups" is set if that pullup 5888c2ecf20Sopenharmony_ci * should be enabled. Else, if that bit is set in "pulldowns", 5898c2ecf20Sopenharmony_ci * that pulldown is enabled. Don't waste power by letting any 5908c2ecf20Sopenharmony_ci * digital inputs float... 5918c2ecf20Sopenharmony_ci */ 5928c2ecf20Sopenharmony_ci u32 pullups; 5938c2ecf20Sopenharmony_ci u32 pulldowns; 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ci int (*setup)(struct device *dev, 5968c2ecf20Sopenharmony_ci unsigned gpio, unsigned ngpio); 5978c2ecf20Sopenharmony_ci int (*teardown)(struct device *dev, 5988c2ecf20Sopenharmony_ci unsigned gpio, unsigned ngpio); 5998c2ecf20Sopenharmony_ci}; 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_cistruct twl4030_madc_platform_data { 6028c2ecf20Sopenharmony_ci int irq_line; 6038c2ecf20Sopenharmony_ci}; 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci/* Boards have unique mappings of {row, col} --> keycode. 6068c2ecf20Sopenharmony_ci * Column and row are 8 bits each, but range only from 0..7. 6078c2ecf20Sopenharmony_ci * a PERSISTENT_KEY is "always on" and never reported. 6088c2ecf20Sopenharmony_ci */ 6098c2ecf20Sopenharmony_ci#define PERSISTENT_KEY(r, c) KEY((r), (c), KEY_RESERVED) 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_cistruct twl4030_keypad_data { 6128c2ecf20Sopenharmony_ci const struct matrix_keymap_data *keymap_data; 6138c2ecf20Sopenharmony_ci unsigned rows; 6148c2ecf20Sopenharmony_ci unsigned cols; 6158c2ecf20Sopenharmony_ci bool rep; 6168c2ecf20Sopenharmony_ci}; 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_cienum twl4030_usb_mode { 6198c2ecf20Sopenharmony_ci T2_USB_MODE_ULPI = 1, 6208c2ecf20Sopenharmony_ci T2_USB_MODE_CEA2011_3PIN = 2, 6218c2ecf20Sopenharmony_ci}; 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_cistruct twl4030_usb_data { 6248c2ecf20Sopenharmony_ci enum twl4030_usb_mode usb_mode; 6258c2ecf20Sopenharmony_ci unsigned long features; 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci int (*phy_init)(struct device *dev); 6288c2ecf20Sopenharmony_ci int (*phy_exit)(struct device *dev); 6298c2ecf20Sopenharmony_ci /* Power on/off the PHY */ 6308c2ecf20Sopenharmony_ci int (*phy_power)(struct device *dev, int iD, int on); 6318c2ecf20Sopenharmony_ci /* enable/disable phy clocks */ 6328c2ecf20Sopenharmony_ci int (*phy_set_clock)(struct device *dev, int on); 6338c2ecf20Sopenharmony_ci /* suspend/resume of phy */ 6348c2ecf20Sopenharmony_ci int (*phy_suspend)(struct device *dev, int suspend); 6358c2ecf20Sopenharmony_ci}; 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_cistruct twl4030_ins { 6388c2ecf20Sopenharmony_ci u16 pmb_message; 6398c2ecf20Sopenharmony_ci u8 delay; 6408c2ecf20Sopenharmony_ci}; 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_cistruct twl4030_script { 6438c2ecf20Sopenharmony_ci struct twl4030_ins *script; 6448c2ecf20Sopenharmony_ci unsigned size; 6458c2ecf20Sopenharmony_ci u8 flags; 6468c2ecf20Sopenharmony_ci#define TWL4030_WRST_SCRIPT (1<<0) 6478c2ecf20Sopenharmony_ci#define TWL4030_WAKEUP12_SCRIPT (1<<1) 6488c2ecf20Sopenharmony_ci#define TWL4030_WAKEUP3_SCRIPT (1<<2) 6498c2ecf20Sopenharmony_ci#define TWL4030_SLEEP_SCRIPT (1<<3) 6508c2ecf20Sopenharmony_ci}; 6518c2ecf20Sopenharmony_ci 6528c2ecf20Sopenharmony_cistruct twl4030_resconfig { 6538c2ecf20Sopenharmony_ci u8 resource; 6548c2ecf20Sopenharmony_ci u8 devgroup; /* Processor group that Power resource belongs to */ 6558c2ecf20Sopenharmony_ci u8 type; /* Power resource addressed, 6 / broadcast message */ 6568c2ecf20Sopenharmony_ci u8 type2; /* Power resource addressed, 3 / broadcast message */ 6578c2ecf20Sopenharmony_ci u8 remap_off; /* off state remapping */ 6588c2ecf20Sopenharmony_ci u8 remap_sleep; /* sleep state remapping */ 6598c2ecf20Sopenharmony_ci}; 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_cistruct twl4030_power_data { 6628c2ecf20Sopenharmony_ci struct twl4030_script **scripts; 6638c2ecf20Sopenharmony_ci unsigned num; 6648c2ecf20Sopenharmony_ci struct twl4030_resconfig *resource_config; 6658c2ecf20Sopenharmony_ci struct twl4030_resconfig *board_config; 6668c2ecf20Sopenharmony_ci#define TWL4030_RESCONFIG_UNDEF ((u8)-1) 6678c2ecf20Sopenharmony_ci bool use_poweroff; /* Board is wired for TWL poweroff */ 6688c2ecf20Sopenharmony_ci bool ac_charger_quirk; /* Disable AC charger on board */ 6698c2ecf20Sopenharmony_ci}; 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_ciextern int twl4030_remove_script(u8 flags); 6728c2ecf20Sopenharmony_ciextern void twl4030_power_off(void); 6738c2ecf20Sopenharmony_ci 6748c2ecf20Sopenharmony_cistruct twl4030_codec_data { 6758c2ecf20Sopenharmony_ci unsigned int digimic_delay; /* in ms */ 6768c2ecf20Sopenharmony_ci unsigned int ramp_delay_value; 6778c2ecf20Sopenharmony_ci unsigned int offset_cncl_path; 6788c2ecf20Sopenharmony_ci unsigned int hs_extmute:1; 6798c2ecf20Sopenharmony_ci int hs_extmute_gpio; 6808c2ecf20Sopenharmony_ci}; 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_cistruct twl4030_vibra_data { 6838c2ecf20Sopenharmony_ci unsigned int coexist; 6848c2ecf20Sopenharmony_ci}; 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_cistruct twl4030_audio_data { 6878c2ecf20Sopenharmony_ci unsigned int audio_mclk; 6888c2ecf20Sopenharmony_ci struct twl4030_codec_data *codec; 6898c2ecf20Sopenharmony_ci struct twl4030_vibra_data *vibra; 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ci /* twl6040 */ 6928c2ecf20Sopenharmony_ci int audpwron_gpio; /* audio power-on gpio */ 6938c2ecf20Sopenharmony_ci int naudint_irq; /* audio interrupt */ 6948c2ecf20Sopenharmony_ci unsigned int irq_base; 6958c2ecf20Sopenharmony_ci}; 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_cistruct twl4030_platform_data { 6988c2ecf20Sopenharmony_ci struct twl4030_clock_init_data *clock; 6998c2ecf20Sopenharmony_ci struct twl4030_bci_platform_data *bci; 7008c2ecf20Sopenharmony_ci struct twl4030_gpio_platform_data *gpio; 7018c2ecf20Sopenharmony_ci struct twl4030_madc_platform_data *madc; 7028c2ecf20Sopenharmony_ci struct twl4030_keypad_data *keypad; 7038c2ecf20Sopenharmony_ci struct twl4030_usb_data *usb; 7048c2ecf20Sopenharmony_ci struct twl4030_power_data *power; 7058c2ecf20Sopenharmony_ci struct twl4030_audio_data *audio; 7068c2ecf20Sopenharmony_ci 7078c2ecf20Sopenharmony_ci /* Common LDO regulators for TWL4030/TWL6030 */ 7088c2ecf20Sopenharmony_ci struct regulator_init_data *vdac; 7098c2ecf20Sopenharmony_ci struct regulator_init_data *vaux1; 7108c2ecf20Sopenharmony_ci struct regulator_init_data *vaux2; 7118c2ecf20Sopenharmony_ci struct regulator_init_data *vaux3; 7128c2ecf20Sopenharmony_ci struct regulator_init_data *vdd1; 7138c2ecf20Sopenharmony_ci struct regulator_init_data *vdd2; 7148c2ecf20Sopenharmony_ci struct regulator_init_data *vdd3; 7158c2ecf20Sopenharmony_ci /* TWL4030 LDO regulators */ 7168c2ecf20Sopenharmony_ci struct regulator_init_data *vpll1; 7178c2ecf20Sopenharmony_ci struct regulator_init_data *vpll2; 7188c2ecf20Sopenharmony_ci struct regulator_init_data *vmmc1; 7198c2ecf20Sopenharmony_ci struct regulator_init_data *vmmc2; 7208c2ecf20Sopenharmony_ci struct regulator_init_data *vsim; 7218c2ecf20Sopenharmony_ci struct regulator_init_data *vaux4; 7228c2ecf20Sopenharmony_ci struct regulator_init_data *vio; 7238c2ecf20Sopenharmony_ci struct regulator_init_data *vintana1; 7248c2ecf20Sopenharmony_ci struct regulator_init_data *vintana2; 7258c2ecf20Sopenharmony_ci struct regulator_init_data *vintdig; 7268c2ecf20Sopenharmony_ci /* TWL6030 LDO regulators */ 7278c2ecf20Sopenharmony_ci struct regulator_init_data *vmmc; 7288c2ecf20Sopenharmony_ci struct regulator_init_data *vpp; 7298c2ecf20Sopenharmony_ci struct regulator_init_data *vusim; 7308c2ecf20Sopenharmony_ci struct regulator_init_data *vana; 7318c2ecf20Sopenharmony_ci struct regulator_init_data *vcxio; 7328c2ecf20Sopenharmony_ci struct regulator_init_data *vusb; 7338c2ecf20Sopenharmony_ci struct regulator_init_data *clk32kg; 7348c2ecf20Sopenharmony_ci struct regulator_init_data *v1v8; 7358c2ecf20Sopenharmony_ci struct regulator_init_data *v2v1; 7368c2ecf20Sopenharmony_ci /* TWL6032 LDO regulators */ 7378c2ecf20Sopenharmony_ci struct regulator_init_data *ldo1; 7388c2ecf20Sopenharmony_ci struct regulator_init_data *ldo2; 7398c2ecf20Sopenharmony_ci struct regulator_init_data *ldo3; 7408c2ecf20Sopenharmony_ci struct regulator_init_data *ldo4; 7418c2ecf20Sopenharmony_ci struct regulator_init_data *ldo5; 7428c2ecf20Sopenharmony_ci struct regulator_init_data *ldo6; 7438c2ecf20Sopenharmony_ci struct regulator_init_data *ldo7; 7448c2ecf20Sopenharmony_ci struct regulator_init_data *ldoln; 7458c2ecf20Sopenharmony_ci struct regulator_init_data *ldousb; 7468c2ecf20Sopenharmony_ci /* TWL6032 DCDC regulators */ 7478c2ecf20Sopenharmony_ci struct regulator_init_data *smps3; 7488c2ecf20Sopenharmony_ci struct regulator_init_data *smps4; 7498c2ecf20Sopenharmony_ci struct regulator_init_data *vio6025; 7508c2ecf20Sopenharmony_ci}; 7518c2ecf20Sopenharmony_ci 7528c2ecf20Sopenharmony_cistruct twl_regulator_driver_data { 7538c2ecf20Sopenharmony_ci int (*set_voltage)(void *data, int target_uV); 7548c2ecf20Sopenharmony_ci int (*get_voltage)(void *data); 7558c2ecf20Sopenharmony_ci void *data; 7568c2ecf20Sopenharmony_ci unsigned long features; 7578c2ecf20Sopenharmony_ci}; 7588c2ecf20Sopenharmony_ci/* chip-specific feature flags, for twl_regulator_driver_data.features */ 7598c2ecf20Sopenharmony_ci#define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */ 7608c2ecf20Sopenharmony_ci#define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */ 7618c2ecf20Sopenharmony_ci#define TWL5031 BIT(2) /* twl5031 has different registers */ 7628c2ecf20Sopenharmony_ci#define TWL6030_CLASS BIT(3) /* TWL6030 class */ 7638c2ecf20Sopenharmony_ci#define TWL6032_SUBCLASS BIT(4) /* TWL6032 has changed registers */ 7648c2ecf20Sopenharmony_ci#define TWL4030_ALLOW_UNSUPPORTED BIT(5) /* Some voltages are possible 7658c2ecf20Sopenharmony_ci * but not officially supported. 7668c2ecf20Sopenharmony_ci * This flag is necessary to 7678c2ecf20Sopenharmony_ci * enable them. 7688c2ecf20Sopenharmony_ci */ 7698c2ecf20Sopenharmony_ci 7708c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 7718c2ecf20Sopenharmony_ci 7728c2ecf20Sopenharmony_ciint twl4030_sih_setup(struct device *dev, int module, int irq_base); 7738c2ecf20Sopenharmony_ci 7748c2ecf20Sopenharmony_ci/* Offsets to Power Registers */ 7758c2ecf20Sopenharmony_ci#define TWL4030_VDAC_DEV_GRP 0x3B 7768c2ecf20Sopenharmony_ci#define TWL4030_VDAC_DEDICATED 0x3E 7778c2ecf20Sopenharmony_ci#define TWL4030_VAUX1_DEV_GRP 0x17 7788c2ecf20Sopenharmony_ci#define TWL4030_VAUX1_DEDICATED 0x1A 7798c2ecf20Sopenharmony_ci#define TWL4030_VAUX2_DEV_GRP 0x1B 7808c2ecf20Sopenharmony_ci#define TWL4030_VAUX2_DEDICATED 0x1E 7818c2ecf20Sopenharmony_ci#define TWL4030_VAUX3_DEV_GRP 0x1F 7828c2ecf20Sopenharmony_ci#define TWL4030_VAUX3_DEDICATED 0x22 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_cistatic inline int twl4030charger_usb_en(int enable) { return 0; } 7858c2ecf20Sopenharmony_ci 7868c2ecf20Sopenharmony_ci/*----------------------------------------------------------------------*/ 7878c2ecf20Sopenharmony_ci 7888c2ecf20Sopenharmony_ci/* Linux-specific regulator identifiers ... for now, we only support 7898c2ecf20Sopenharmony_ci * the LDOs, and leave the three buck converters alone. VDD1 and VDD2 7908c2ecf20Sopenharmony_ci * need to tie into hardware based voltage scaling (cpufreq etc), while 7918c2ecf20Sopenharmony_ci * VIO is generally fixed. 7928c2ecf20Sopenharmony_ci */ 7938c2ecf20Sopenharmony_ci 7948c2ecf20Sopenharmony_ci/* TWL4030 SMPS/LDO's */ 7958c2ecf20Sopenharmony_ci/* EXTERNAL dc-to-dc buck converters */ 7968c2ecf20Sopenharmony_ci#define TWL4030_REG_VDD1 0 7978c2ecf20Sopenharmony_ci#define TWL4030_REG_VDD2 1 7988c2ecf20Sopenharmony_ci#define TWL4030_REG_VIO 2 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ci/* EXTERNAL LDOs */ 8018c2ecf20Sopenharmony_ci#define TWL4030_REG_VDAC 3 8028c2ecf20Sopenharmony_ci#define TWL4030_REG_VPLL1 4 8038c2ecf20Sopenharmony_ci#define TWL4030_REG_VPLL2 5 /* not on all chips */ 8048c2ecf20Sopenharmony_ci#define TWL4030_REG_VMMC1 6 8058c2ecf20Sopenharmony_ci#define TWL4030_REG_VMMC2 7 /* not on all chips */ 8068c2ecf20Sopenharmony_ci#define TWL4030_REG_VSIM 8 /* not on all chips */ 8078c2ecf20Sopenharmony_ci#define TWL4030_REG_VAUX1 9 /* not on all chips */ 8088c2ecf20Sopenharmony_ci#define TWL4030_REG_VAUX2_4030 10 /* (twl4030-specific) */ 8098c2ecf20Sopenharmony_ci#define TWL4030_REG_VAUX2 11 /* (twl5030 and newer) */ 8108c2ecf20Sopenharmony_ci#define TWL4030_REG_VAUX3 12 /* not on all chips */ 8118c2ecf20Sopenharmony_ci#define TWL4030_REG_VAUX4 13 /* not on all chips */ 8128c2ecf20Sopenharmony_ci 8138c2ecf20Sopenharmony_ci/* INTERNAL LDOs */ 8148c2ecf20Sopenharmony_ci#define TWL4030_REG_VINTANA1 14 8158c2ecf20Sopenharmony_ci#define TWL4030_REG_VINTANA2 15 8168c2ecf20Sopenharmony_ci#define TWL4030_REG_VINTDIG 16 8178c2ecf20Sopenharmony_ci#define TWL4030_REG_VUSB1V5 17 8188c2ecf20Sopenharmony_ci#define TWL4030_REG_VUSB1V8 18 8198c2ecf20Sopenharmony_ci#define TWL4030_REG_VUSB3V1 19 8208c2ecf20Sopenharmony_ci 8218c2ecf20Sopenharmony_ci/* TWL6030 SMPS/LDO's */ 8228c2ecf20Sopenharmony_ci/* EXTERNAL dc-to-dc buck convertor controllable via SR */ 8238c2ecf20Sopenharmony_ci#define TWL6030_REG_VDD1 30 8248c2ecf20Sopenharmony_ci#define TWL6030_REG_VDD2 31 8258c2ecf20Sopenharmony_ci#define TWL6030_REG_VDD3 32 8268c2ecf20Sopenharmony_ci 8278c2ecf20Sopenharmony_ci/* Non SR compliant dc-to-dc buck convertors */ 8288c2ecf20Sopenharmony_ci#define TWL6030_REG_VMEM 33 8298c2ecf20Sopenharmony_ci#define TWL6030_REG_V2V1 34 8308c2ecf20Sopenharmony_ci#define TWL6030_REG_V1V29 35 8318c2ecf20Sopenharmony_ci#define TWL6030_REG_V1V8 36 8328c2ecf20Sopenharmony_ci 8338c2ecf20Sopenharmony_ci/* EXTERNAL LDOs */ 8348c2ecf20Sopenharmony_ci#define TWL6030_REG_VAUX1_6030 37 8358c2ecf20Sopenharmony_ci#define TWL6030_REG_VAUX2_6030 38 8368c2ecf20Sopenharmony_ci#define TWL6030_REG_VAUX3_6030 39 8378c2ecf20Sopenharmony_ci#define TWL6030_REG_VMMC 40 8388c2ecf20Sopenharmony_ci#define TWL6030_REG_VPP 41 8398c2ecf20Sopenharmony_ci#define TWL6030_REG_VUSIM 42 8408c2ecf20Sopenharmony_ci#define TWL6030_REG_VANA 43 8418c2ecf20Sopenharmony_ci#define TWL6030_REG_VCXIO 44 8428c2ecf20Sopenharmony_ci#define TWL6030_REG_VDAC 45 8438c2ecf20Sopenharmony_ci#define TWL6030_REG_VUSB 46 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ci/* INTERNAL LDOs */ 8468c2ecf20Sopenharmony_ci#define TWL6030_REG_VRTC 47 8478c2ecf20Sopenharmony_ci#define TWL6030_REG_CLK32KG 48 8488c2ecf20Sopenharmony_ci 8498c2ecf20Sopenharmony_ci/* LDOs on 6025 have different names */ 8508c2ecf20Sopenharmony_ci#define TWL6032_REG_LDO2 49 8518c2ecf20Sopenharmony_ci#define TWL6032_REG_LDO4 50 8528c2ecf20Sopenharmony_ci#define TWL6032_REG_LDO3 51 8538c2ecf20Sopenharmony_ci#define TWL6032_REG_LDO5 52 8548c2ecf20Sopenharmony_ci#define TWL6032_REG_LDO1 53 8558c2ecf20Sopenharmony_ci#define TWL6032_REG_LDO7 54 8568c2ecf20Sopenharmony_ci#define TWL6032_REG_LDO6 55 8578c2ecf20Sopenharmony_ci#define TWL6032_REG_LDOLN 56 8588c2ecf20Sopenharmony_ci#define TWL6032_REG_LDOUSB 57 8598c2ecf20Sopenharmony_ci 8608c2ecf20Sopenharmony_ci/* 6025 DCDC supplies */ 8618c2ecf20Sopenharmony_ci#define TWL6032_REG_SMPS3 58 8628c2ecf20Sopenharmony_ci#define TWL6032_REG_SMPS4 59 8638c2ecf20Sopenharmony_ci#define TWL6032_REG_VIO 60 8648c2ecf20Sopenharmony_ci 8658c2ecf20Sopenharmony_ci 8668c2ecf20Sopenharmony_ci#endif /* End of __TWL4030_H */ 867