Uwe Kleine-König | 8e00593 | 2010-09-28 16:37:20 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2009-2010 Pengutronix |
| 3 | * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it under |
| 6 | * the terms of the GNU General Public License version 2 as published by the |
| 7 | * Free Software Foundation. |
| 8 | */ |
| 9 | #ifndef __LINUX_MFD_MC13XXX_H |
| 10 | #define __LINUX_MFD_MC13XXX_H |
| 11 | |
| 12 | #include <linux/interrupt.h> |
| 13 | |
| 14 | struct mc13xxx; |
| 15 | |
| 16 | void mc13xxx_lock(struct mc13xxx *mc13xxx); |
| 17 | void mc13xxx_unlock(struct mc13xxx *mc13xxx); |
| 18 | |
| 19 | int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val); |
| 20 | int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val); |
| 21 | int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset, |
| 22 | u32 mask, u32 val); |
| 23 | |
| 24 | int mc13xxx_get_flags(struct mc13xxx *mc13xxx); |
| 25 | |
| 26 | int mc13xxx_irq_request(struct mc13xxx *mc13xxx, int irq, |
| 27 | irq_handler_t handler, const char *name, void *dev); |
| 28 | int mc13xxx_irq_request_nounmask(struct mc13xxx *mc13xxx, int irq, |
| 29 | irq_handler_t handler, const char *name, void *dev); |
| 30 | int mc13xxx_irq_free(struct mc13xxx *mc13xxx, int irq, void *dev); |
| 31 | |
| 32 | int mc13xxx_irq_mask(struct mc13xxx *mc13xxx, int irq); |
| 33 | int mc13xxx_irq_unmask(struct mc13xxx *mc13xxx, int irq); |
| 34 | int mc13xxx_irq_status(struct mc13xxx *mc13xxx, int irq, |
| 35 | int *enabled, int *pending); |
| 36 | int mc13xxx_irq_ack(struct mc13xxx *mc13xxx, int irq); |
| 37 | |
| 38 | int mc13xxx_get_flags(struct mc13xxx *mc13xxx); |
| 39 | |
Uwe Kleine-König | fec316d | 2011-08-24 15:28:21 +0200 | [diff] [blame] | 40 | int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, |
| 41 | unsigned int mode, unsigned int channel, unsigned int *sample); |
| 42 | |
Uwe Kleine-König | 8e00593 | 2010-09-28 16:37:20 +0200 | [diff] [blame] | 43 | #define MC13XXX_IRQ_ADCDONE 0 |
| 44 | #define MC13XXX_IRQ_ADCBISDONE 1 |
| 45 | #define MC13XXX_IRQ_TS 2 |
| 46 | #define MC13XXX_IRQ_CHGDET 6 |
| 47 | #define MC13XXX_IRQ_CHGREV 8 |
| 48 | #define MC13XXX_IRQ_CHGSHORT 9 |
| 49 | #define MC13XXX_IRQ_CCCV 10 |
| 50 | #define MC13XXX_IRQ_CHGCURR 11 |
| 51 | #define MC13XXX_IRQ_BPON 12 |
| 52 | #define MC13XXX_IRQ_LOBATL 13 |
| 53 | #define MC13XXX_IRQ_LOBATH 14 |
| 54 | #define MC13XXX_IRQ_1HZ 24 |
| 55 | #define MC13XXX_IRQ_TODA 25 |
| 56 | #define MC13XXX_IRQ_SYSRST 30 |
| 57 | #define MC13XXX_IRQ_RTCRST 31 |
| 58 | #define MC13XXX_IRQ_PC 32 |
| 59 | #define MC13XXX_IRQ_WARM 33 |
| 60 | #define MC13XXX_IRQ_MEMHLD 34 |
| 61 | #define MC13XXX_IRQ_THWARNL 36 |
| 62 | #define MC13XXX_IRQ_THWARNH 37 |
| 63 | #define MC13XXX_IRQ_CLK 38 |
| 64 | |
| 65 | #define MC13XXX_NUM_IRQ 46 |
| 66 | |
| 67 | struct regulator_init_data; |
| 68 | |
| 69 | struct mc13xxx_regulator_init_data { |
| 70 | int id; |
| 71 | struct regulator_init_data *init_data; |
Shawn Guo | 93bcb23 | 2011-12-21 23:00:46 +0800 | [diff] [blame] | 72 | struct device_node *node; |
Uwe Kleine-König | 8e00593 | 2010-09-28 16:37:20 +0200 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | struct mc13xxx_regulator_platform_data { |
| 76 | int num_regulators; |
| 77 | struct mc13xxx_regulator_init_data *regulators; |
| 78 | }; |
| 79 | |
| 80 | struct mc13xxx_led_platform_data { |
| 81 | #define MC13783_LED_MD 0 |
| 82 | #define MC13783_LED_AD 1 |
| 83 | #define MC13783_LED_KP 2 |
| 84 | #define MC13783_LED_R1 3 |
| 85 | #define MC13783_LED_G1 4 |
| 86 | #define MC13783_LED_B1 5 |
| 87 | #define MC13783_LED_R2 6 |
| 88 | #define MC13783_LED_G2 7 |
| 89 | #define MC13783_LED_B2 8 |
| 90 | #define MC13783_LED_R3 9 |
| 91 | #define MC13783_LED_G3 10 |
| 92 | #define MC13783_LED_B3 11 |
| 93 | #define MC13783_LED_MAX MC13783_LED_B3 |
| 94 | int id; |
| 95 | const char *name; |
| 96 | const char *default_trigger; |
| 97 | |
| 98 | /* Three or two bits current selection depending on the led */ |
| 99 | char max_current; |
| 100 | }; |
| 101 | |
| 102 | struct mc13xxx_leds_platform_data { |
| 103 | int num_leds; |
| 104 | struct mc13xxx_led_platform_data *led; |
| 105 | |
| 106 | #define MC13783_LED_TRIODE_MD (1 << 0) |
| 107 | #define MC13783_LED_TRIODE_AD (1 << 1) |
| 108 | #define MC13783_LED_TRIODE_KP (1 << 2) |
| 109 | #define MC13783_LED_BOOST_EN (1 << 3) |
| 110 | #define MC13783_LED_TC1HALF (1 << 4) |
| 111 | #define MC13783_LED_SLEWLIMTC (1 << 5) |
| 112 | #define MC13783_LED_SLEWLIMBL (1 << 6) |
| 113 | #define MC13783_LED_TRIODE_TC1 (1 << 7) |
| 114 | #define MC13783_LED_TRIODE_TC2 (1 << 8) |
| 115 | #define MC13783_LED_TRIODE_TC3 (1 << 9) |
| 116 | int flags; |
| 117 | |
| 118 | #define MC13783_LED_AB_DISABLED 0 |
| 119 | #define MC13783_LED_AB_MD1 1 |
| 120 | #define MC13783_LED_AB_MD12 2 |
| 121 | #define MC13783_LED_AB_MD123 3 |
| 122 | #define MC13783_LED_AB_MD1234 4 |
| 123 | #define MC13783_LED_AB_MD1234_AD1 5 |
| 124 | #define MC13783_LED_AB_MD1234_AD12 6 |
| 125 | #define MC13783_LED_AB_MD1_AD 7 |
| 126 | char abmode; |
| 127 | |
| 128 | #define MC13783_LED_ABREF_200MV 0 |
| 129 | #define MC13783_LED_ABREF_400MV 1 |
| 130 | #define MC13783_LED_ABREF_600MV 2 |
| 131 | #define MC13783_LED_ABREF_800MV 3 |
| 132 | char abref; |
| 133 | |
| 134 | #define MC13783_LED_PERIOD_10MS 0 |
| 135 | #define MC13783_LED_PERIOD_100MS 1 |
| 136 | #define MC13783_LED_PERIOD_500MS 2 |
| 137 | #define MC13783_LED_PERIOD_2S 3 |
| 138 | char bl_period; |
| 139 | char tc1_period; |
| 140 | char tc2_period; |
| 141 | char tc3_period; |
| 142 | }; |
| 143 | |
Philippe Rétornaz | 30fc7ac | 2011-09-18 18:10:53 +0200 | [diff] [blame] | 144 | struct mc13xxx_buttons_platform_data { |
| 145 | #define MC13783_BUTTON_DBNC_0MS 0 |
| 146 | #define MC13783_BUTTON_DBNC_30MS 1 |
| 147 | #define MC13783_BUTTON_DBNC_150MS 2 |
| 148 | #define MC13783_BUTTON_DBNC_750MS 3 |
| 149 | #define MC13783_BUTTON_ENABLE (1 << 2) |
| 150 | #define MC13783_BUTTON_POL_INVERT (1 << 3) |
| 151 | #define MC13783_BUTTON_RESET_EN (1 << 4) |
| 152 | int b1on_flags; |
| 153 | unsigned short b1on_key; |
| 154 | int b2on_flags; |
| 155 | unsigned short b2on_key; |
| 156 | int b3on_flags; |
| 157 | unsigned short b3on_key; |
| 158 | }; |
| 159 | |
Uwe Kleine-König | 8e00593 | 2010-09-28 16:37:20 +0200 | [diff] [blame] | 160 | struct mc13xxx_platform_data { |
| 161 | #define MC13XXX_USE_TOUCHSCREEN (1 << 0) |
| 162 | #define MC13XXX_USE_CODEC (1 << 1) |
| 163 | #define MC13XXX_USE_ADC (1 << 2) |
| 164 | #define MC13XXX_USE_RTC (1 << 3) |
Uwe Kleine-König | 8e00593 | 2010-09-28 16:37:20 +0200 | [diff] [blame] | 165 | unsigned int flags; |
| 166 | |
Andres Salomon | 4ec1b54 | 2011-02-17 19:07:23 -0800 | [diff] [blame] | 167 | struct mc13xxx_regulator_platform_data regulators; |
Uwe Kleine-König | 8e00593 | 2010-09-28 16:37:20 +0200 | [diff] [blame] | 168 | struct mc13xxx_leds_platform_data *leds; |
Philippe Rétornaz | 30fc7ac | 2011-09-18 18:10:53 +0200 | [diff] [blame] | 169 | struct mc13xxx_buttons_platform_data *buttons; |
Uwe Kleine-König | 8e00593 | 2010-09-28 16:37:20 +0200 | [diff] [blame] | 170 | }; |
| 171 | |
Uwe Kleine-König | fec316d | 2011-08-24 15:28:21 +0200 | [diff] [blame] | 172 | #define MC13XXX_ADC_MODE_TS 1 |
| 173 | #define MC13XXX_ADC_MODE_SINGLE_CHAN 2 |
| 174 | #define MC13XXX_ADC_MODE_MULT_CHAN 3 |
| 175 | |
| 176 | #define MC13XXX_ADC0 43 |
Robin van der Gracht | 2161891 | 2011-11-29 12:09:03 +0100 | [diff] [blame] | 177 | #define MC13XXX_ADC0_LICELLCON (1 << 0) |
| 178 | #define MC13XXX_ADC0_CHRGICON (1 << 1) |
| 179 | #define MC13XXX_ADC0_BATICON (1 << 2) |
Uwe Kleine-König | fec316d | 2011-08-24 15:28:21 +0200 | [diff] [blame] | 180 | #define MC13XXX_ADC0_ADREFEN (1 << 10) |
| 181 | #define MC13XXX_ADC0_TSMOD0 (1 << 12) |
| 182 | #define MC13XXX_ADC0_TSMOD1 (1 << 13) |
| 183 | #define MC13XXX_ADC0_TSMOD2 (1 << 14) |
| 184 | #define MC13XXX_ADC0_ADINC1 (1 << 16) |
| 185 | #define MC13XXX_ADC0_ADINC2 (1 << 17) |
| 186 | |
| 187 | #define MC13XXX_ADC0_TSMOD_MASK (MC13XXX_ADC0_TSMOD0 | \ |
| 188 | MC13XXX_ADC0_TSMOD1 | \ |
| 189 | MC13XXX_ADC0_TSMOD2) |
| 190 | |
Robin van der Gracht | 2161891 | 2011-11-29 12:09:03 +0100 | [diff] [blame] | 191 | #define MC13XXX_ADC0_CONFIG_MASK (MC13XXX_ADC0_TSMOD_MASK | \ |
| 192 | MC13XXX_ADC0_LICELLCON | \ |
| 193 | MC13XXX_ADC0_CHRGICON | \ |
| 194 | MC13XXX_ADC0_BATICON) |
| 195 | |
Uwe Kleine-König | 8e00593 | 2010-09-28 16:37:20 +0200 | [diff] [blame] | 196 | #endif /* ifndef __LINUX_MFD_MC13XXX_H */ |