| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 1 | /* |
| 2 | * include/linux/mfd/max77663-core.h |
| 3 | * |
| 4 | * Copyright 2011 Maxim Integrated Products, Inc. |
| Johnny Qiu | 526eec4 | 2012-02-08 17:11:22 +0800 | [diff] [blame] | 5 | * Copyright (C) 2011-2012 NVIDIA Corporation |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of the |
| 10 | * License, or (at your option) any later version. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef __LINUX_MFD_MAX77663_CORE_H__ |
| 15 | #define __LINUX_MFD_MAX77663_CORE_H__ |
| 16 | |
| 17 | #include <linux/irq.h> |
| 18 | #include <linux/mfd/core.h> |
| 19 | |
| 20 | /* |
| 21 | * Interrupts |
| 22 | */ |
| 23 | enum { |
| Laxman Dewangan | e17768e | 2012-08-22 16:42:46 +0530 | [diff] [blame] | 24 | MAX77663_IRQ_INT_TOP_GPIO, /* TOP GPIO internal int to max77663 */ |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 25 | MAX77663_IRQ_LBT_LB, /* Low-Battery */ |
| 26 | MAX77663_IRQ_LBT_THERM_ALRM1, /* Thermal alarm status, > 120C */ |
| 27 | MAX77663_IRQ_LBT_THERM_ALRM2, /* Thermal alarm status, > 140C */ |
| 28 | |
| 29 | MAX77663_IRQ_GPIO0, /* GPIO0 edge detection */ |
| 30 | MAX77663_IRQ_GPIO1, /* GPIO1 edge detection */ |
| 31 | MAX77663_IRQ_GPIO2, /* GPIO2 edge detection */ |
| 32 | MAX77663_IRQ_GPIO3, /* GPIO3 edge detection */ |
| 33 | MAX77663_IRQ_GPIO4, /* GPIO4 edge detection */ |
| 34 | MAX77663_IRQ_GPIO5, /* GPIO5 edge detection */ |
| 35 | MAX77663_IRQ_GPIO6, /* GPIO6 edge detection */ |
| 36 | MAX77663_IRQ_GPIO7, /* GPIO7 edge detection */ |
| 37 | |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 38 | MAX77663_IRQ_ONOFF_HRDPOWRN, /* Hard power off warnning */ |
| 39 | MAX77663_IRQ_ONOFF_EN0_1SEC, /* EN0 active for 1s */ |
| 40 | MAX77663_IRQ_ONOFF_EN0_FALLING, /* EN0 falling */ |
| 41 | MAX77663_IRQ_ONOFF_EN0_RISING, /* EN0 rising */ |
| 42 | MAX77663_IRQ_ONOFF_LID_FALLING, /* LID falling */ |
| 43 | MAX77663_IRQ_ONOFF_LID_RISING, /* LID rising */ |
| 44 | MAX77663_IRQ_ONOFF_ACOK_FALLING,/* ACOK falling */ |
| 45 | MAX77663_IRQ_ONOFF_ACOK_RISING, /* ACOK rising */ |
| 46 | |
| Jin Park | c16a27a | 2011-08-29 11:47:40 +0900 | [diff] [blame] | 47 | MAX77663_IRQ_RTC, /* RTC */ |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 48 | MAX77663_IRQ_SD_PF, /* SD power fail */ |
| 49 | MAX77663_IRQ_LDO_PF, /* LDO power fail */ |
| 50 | MAX77663_IRQ_32K, /* 32kHz oscillator */ |
| 51 | MAX77663_IRQ_NVER, /* Non-Volatile Event Recorder */ |
| 52 | |
| 53 | MAX77663_IRQ_NR, |
| 54 | }; |
| 55 | |
| 56 | /* |
| 57 | *GPIOs |
| 58 | */ |
| 59 | enum { |
| 60 | MAX77663_GPIO0, |
| 61 | MAX77663_GPIO1, |
| 62 | MAX77663_GPIO2, |
| 63 | MAX77663_GPIO3, |
| 64 | MAX77663_GPIO4, |
| 65 | MAX77663_GPIO5, |
| 66 | MAX77663_GPIO6, |
| 67 | MAX77663_GPIO7, |
| 68 | |
| 69 | MAX77663_GPIO_NR, |
| 70 | }; |
| 71 | |
| Jin Park | 543ca9a | 2011-09-26 14:51:20 +0900 | [diff] [blame] | 72 | /* Direction */ |
| 73 | enum max77663_gpio_dir { |
| 74 | GPIO_DIR_DEF, |
| 75 | GPIO_DIR_IN, |
| 76 | GPIO_DIR_OUT, |
| 77 | }; |
| 78 | |
| 79 | /* Data output */ |
| 80 | enum max77663_gpio_data_out { |
| 81 | GPIO_DOUT_DEF, |
| 82 | GPIO_DOUT_HIGH, |
| 83 | GPIO_DOUT_LOW, |
| 84 | }; |
| 85 | |
| 86 | /* Output drive */ |
| 87 | enum max77663_gpio_out_drv { |
| 88 | GPIO_OUT_DRV_DEF, |
| 89 | GPIO_OUT_DRV_PUSH_PULL, |
| 90 | GPIO_OUT_DRV_OPEN_DRAIN, |
| 91 | }; |
| 92 | |
| 93 | /* Pull-up */ |
| 94 | enum max77663_gpio_pull_up { |
| 95 | GPIO_PU_DEF, |
| 96 | GPIO_PU_ENABLE, |
| 97 | GPIO_PU_DISABLE, |
| 98 | }; |
| 99 | |
| 100 | /* Pull-down */ |
| 101 | enum max77663_gpio_pull_down { |
| 102 | GPIO_PD_DEF, |
| 103 | GPIO_PD_ENABLE, |
| 104 | GPIO_PD_DISABLE, |
| 105 | }; |
| 106 | |
| 107 | /* Alternate */ |
| 108 | enum max77663_gpio_alt { |
| 109 | GPIO_ALT_DEF, |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 110 | GPIO_ALT_ENABLE, |
| Jin Park | 543ca9a | 2011-09-26 14:51:20 +0900 | [diff] [blame] | 111 | GPIO_ALT_DISABLE, |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 112 | }; |
| 113 | |
| Sumit Sharma | a71cd7b | 2013-02-06 16:19:12 +0530 | [diff] [blame] | 114 | enum max77663_chip_version { |
| 115 | MAX77663_DRV_NOT_DEFINED, |
| 116 | MAX77663_DRV_10, |
| 117 | MAX77663_DRV_12, |
| 118 | MAX77663_DRV_1A, |
| 119 | MAX77663_DRV_1B, |
| 120 | MAX77663_DRV_1E, |
| 121 | MAX77663_DRV_20, |
| 122 | MAX77663_DRV_22, |
| 123 | MAX77663_DRV_24, |
| 124 | }; |
| Jin Park | 31c44d0 | 2012-01-17 14:48:47 +0900 | [diff] [blame] | 125 | /* |
| 126 | * Flags |
| 127 | */ |
| 128 | #define SLP_LPM_ENABLE 0x01 |
| 129 | |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 130 | struct max77663_gpio_config { |
| 131 | int gpio; /* gpio number */ |
| Jin Park | 543ca9a | 2011-09-26 14:51:20 +0900 | [diff] [blame] | 132 | enum max77663_gpio_dir dir; |
| 133 | enum max77663_gpio_data_out dout; |
| 134 | enum max77663_gpio_out_drv out_drv; |
| 135 | enum max77663_gpio_pull_up pull_up; |
| 136 | enum max77663_gpio_pull_down pull_down; |
| 137 | enum max77663_gpio_alt alternate; |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | struct max77663_platform_data { |
| 141 | int irq_base; |
| 142 | int gpio_base; |
| Jin Park | 543ca9a | 2011-09-26 14:51:20 +0900 | [diff] [blame] | 143 | |
| 144 | int num_gpio_cfgs; |
| 145 | struct max77663_gpio_config *gpio_cfgs; |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 146 | |
| 147 | int num_subdevs; |
| 148 | struct mfd_cell *sub_devices; |
| Jin Park | 31c44d0 | 2012-01-17 14:48:47 +0900 | [diff] [blame] | 149 | |
| Laxman Dewangan | 7eb20d8 | 2012-08-28 12:16:33 +0530 | [diff] [blame] | 150 | struct max77663_regulator_platform_data **regulator_pdata; |
| 151 | int num_regulator_pdata; |
| 152 | |
| Jin Park | 31c44d0 | 2012-01-17 14:48:47 +0900 | [diff] [blame] | 153 | unsigned int flags; |
| Johnny Qiu | 526eec4 | 2012-02-08 17:11:22 +0800 | [diff] [blame] | 154 | |
| 155 | unsigned char rtc_i2c_addr; |
| Dan Willemsen | 30afacb | 2011-12-01 15:08:56 -0800 | [diff] [blame] | 156 | |
| 157 | bool use_power_off; |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 158 | }; |
| 159 | |
| Jin Park | 946644d | 2011-10-10 13:05:56 +0900 | [diff] [blame] | 160 | #if defined(CONFIG_MFD_MAX77663) |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 161 | int max77663_read(struct device *dev, u8 addr, void *values, u32 len, |
| 162 | bool is_rtc); |
| 163 | int max77663_write(struct device *dev, u8 addr, void *values, u32 len, |
| 164 | bool is_rtc); |
| 165 | int max77663_set_bits(struct device *dev, u8 addr, u8 mask, u8 value, |
| 166 | bool is_rtc); |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 167 | int max77663_gpio_set_alternate(int gpio, int alternate); |
| Sumit Sharma | a71cd7b | 2013-02-06 16:19:12 +0530 | [diff] [blame] | 168 | int max77663_read_chip_version(struct device *dev, u8 *val); |
| Jin Park | 946644d | 2011-10-10 13:05:56 +0900 | [diff] [blame] | 169 | #else |
| 170 | static inline int max77663_read(struct device *dev, u8 addr, void *values, |
| 171 | u32 len, bool is_rtc) |
| 172 | { |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | static inline int max77663_write(struct device *dev, u8 addr, void *values, |
| 177 | u32 len, bool is_rtc) |
| 178 | { |
| 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | static inline int max77663_set_bits(struct device *dev, u8 addr, u8 mask, |
| 183 | u8 value, bool is_rtc) |
| 184 | { |
| 185 | return 0; |
| 186 | } |
| 187 | |
| Jin Park | 946644d | 2011-10-10 13:05:56 +0900 | [diff] [blame] | 188 | static inline int max77663_gpio_set_alternate(int gpio, int alternate) |
| 189 | { |
| 190 | return 0; |
| 191 | } |
| Sumit Sharma | a71cd7b | 2013-02-06 16:19:12 +0530 | [diff] [blame] | 192 | |
| 193 | static inline int max77663_read_chip_version(struct device *dev, u8 *val) |
| 194 | { |
| 195 | return 0; |
| 196 | } |
| Jin Park | 946644d | 2011-10-10 13:05:56 +0900 | [diff] [blame] | 197 | #endif /* defined(CONFIG_MFD_MAX77663) */ |
| Jin Park | 040c055 | 2011-08-02 16:04:54 +0900 | [diff] [blame] | 198 | |
| 199 | #endif /* __LINUX_MFD_MAX77663_CORE_H__ */ |