Stephan Gerhold | cb9589f | 2021-07-08 20:33:48 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* |
| 3 | * Based on include/linux/mfd/abx500/ab8500.h from Linux |
| 4 | * Copyright (C) ST-Ericsson SA 2010 |
| 5 | * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> |
| 6 | */ |
| 7 | |
| 8 | #ifndef _PMIC_AB8500_H_ |
| 9 | #define _PMIC_AB8500_H_ |
| 10 | |
| 11 | /* |
| 12 | * AB IC versions |
| 13 | * |
| 14 | * AB8500_VERSION_AB8500 should be 0xFF but will never be read as need a |
| 15 | * non-supported multi-byte I2C access via PRCMU. Set to 0x00 to ease the |
| 16 | * print of version string. |
| 17 | */ |
| 18 | enum ab8500_version { |
| 19 | AB8500_VERSION_AB8500 = 0x0, |
| 20 | AB8500_VERSION_AB8505 = 0x1, |
| 21 | AB8500_VERSION_AB9540 = 0x2, |
| 22 | AB8500_VERSION_AB8540 = 0x4, |
| 23 | AB8500_VERSION_UNDEFINED, |
| 24 | }; |
| 25 | |
| 26 | /* AB8500 CIDs*/ |
| 27 | #define AB8500_CUTEARLY 0x00 |
| 28 | #define AB8500_CUT1P0 0x10 |
| 29 | #define AB8500_CUT1P1 0x11 |
| 30 | #define AB8500_CUT1P2 0x12 /* Only valid for AB8540 */ |
| 31 | #define AB8500_CUT2P0 0x20 |
| 32 | #define AB8500_CUT3P0 0x30 |
| 33 | #define AB8500_CUT3P3 0x33 |
| 34 | |
| 35 | /* |
| 36 | * AB8500 bank addresses |
| 37 | */ |
| 38 | #define AB8500_BANK(bank, reg) (((bank) << 8) | (reg)) |
| 39 | #define AB8500_M_FSM_RANK(reg) AB8500_BANK(0x0, reg) |
| 40 | #define AB8500_SYS_CTRL1_BLOCK(reg) AB8500_BANK(0x1, reg) |
| 41 | #define AB8500_SYS_CTRL2_BLOCK(reg) AB8500_BANK(0x2, reg) |
| 42 | #define AB8500_REGU_CTRL1(reg) AB8500_BANK(0x3, reg) |
| 43 | #define AB8500_REGU_CTRL2(reg) AB8500_BANK(0x4, reg) |
| 44 | #define AB8500_USB(reg) AB8500_BANK(0x5, reg) |
| 45 | #define AB8500_TVOUT(reg) AB8500_BANK(0x6, reg) |
| 46 | #define AB8500_DBI(reg) AB8500_BANK(0x7, reg) |
| 47 | #define AB8500_ECI_AV_ACC(reg) AB8500_BANK(0x8, reg) |
| 48 | #define AB8500_RESERVED(reg) AB8500_BANK(0x9, reg) |
| 49 | #define AB8500_GPADC(reg) AB8500_BANK(0xA, reg) |
| 50 | #define AB8500_CHARGER(reg) AB8500_BANK(0xB, reg) |
| 51 | #define AB8500_GAS_GAUGE(reg) AB8500_BANK(0xC, reg) |
| 52 | #define AB8500_AUDIO(reg) AB8500_BANK(0xD, reg) |
| 53 | #define AB8500_INTERRUPT(reg) AB8500_BANK(0xE, reg) |
| 54 | #define AB8500_RTC(reg) AB8500_BANK(0xF, reg) |
| 55 | #define AB8500_GPIO(reg) AB8500_BANK(0x10, reg) |
| 56 | #define AB8500_MISC(reg) AB8500_BANK(0x10, reg) |
| 57 | #define AB8500_DEVELOPMENT(reg) AB8500_BANK(0x11, reg) |
| 58 | #define AB8500_DEBUG(reg) AB8500_BANK(0x12, reg) |
| 59 | #define AB8500_PROD_TEST(reg) AB8500_BANK(0x13, reg) |
| 60 | #define AB8500_STE_TEST(reg) AB8500_BANK(0x14, reg) |
| 61 | #define AB8500_OTP_EMUL(reg) AB8500_BANK(0x15, reg) |
| 62 | |
| 63 | #define AB8500_NUM_BANKS 0x16 |
| 64 | #define AB8500_NUM_REGISTERS AB8500_BANK(AB8500_NUM_BANKS, 0) |
| 65 | |
| 66 | struct ab8500 { |
| 67 | enum ab8500_version version; |
| 68 | u8 chip_id; |
| 69 | }; |
| 70 | |
| 71 | static inline int is_ab8500(struct ab8500 *ab) |
| 72 | { |
| 73 | return ab->version == AB8500_VERSION_AB8500; |
| 74 | } |
| 75 | |
| 76 | static inline int is_ab8505(struct ab8500 *ab) |
| 77 | { |
| 78 | return ab->version == AB8500_VERSION_AB8505; |
| 79 | } |
| 80 | |
| 81 | /* exclude also ab8505, ab9540... */ |
| 82 | static inline int is_ab8500_1p0_or_earlier(struct ab8500 *ab) |
| 83 | { |
| 84 | return (is_ab8500(ab) && (ab->chip_id <= AB8500_CUT1P0)); |
| 85 | } |
| 86 | |
| 87 | /* exclude also ab8505, ab9540... */ |
| 88 | static inline int is_ab8500_1p1_or_earlier(struct ab8500 *ab) |
| 89 | { |
| 90 | return (is_ab8500(ab) && (ab->chip_id <= AB8500_CUT1P1)); |
| 91 | } |
| 92 | |
| 93 | /* exclude also ab8505, ab9540... */ |
| 94 | static inline int is_ab8500_2p0_or_earlier(struct ab8500 *ab) |
| 95 | { |
| 96 | return (is_ab8500(ab) && (ab->chip_id <= AB8500_CUT2P0)); |
| 97 | } |
| 98 | |
| 99 | static inline int is_ab8500_3p3_or_earlier(struct ab8500 *ab) |
| 100 | { |
| 101 | return (is_ab8500(ab) && (ab->chip_id <= AB8500_CUT3P3)); |
| 102 | } |
| 103 | |
| 104 | /* exclude also ab8505, ab9540... */ |
| 105 | static inline int is_ab8500_2p0(struct ab8500 *ab) |
| 106 | { |
| 107 | return (is_ab8500(ab) && (ab->chip_id == AB8500_CUT2P0)); |
| 108 | } |
| 109 | |
| 110 | static inline int is_ab8505_1p0_or_earlier(struct ab8500 *ab) |
| 111 | { |
| 112 | return (is_ab8505(ab) && (ab->chip_id <= AB8500_CUT1P0)); |
| 113 | } |
| 114 | |
| 115 | static inline int is_ab8505_2p0(struct ab8500 *ab) |
| 116 | { |
| 117 | return (is_ab8505(ab) && (ab->chip_id == AB8500_CUT2P0)); |
| 118 | } |
| 119 | |
| 120 | static inline int is_ab8505_2p0_earlier(struct ab8500 *ab) |
| 121 | { |
| 122 | return (is_ab8505(ab) && (ab->chip_id < AB8500_CUT2P0)); |
| 123 | } |
| 124 | |
| 125 | #endif |