rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /***************************************************************************** |
| 37 | * |
| 38 | * Filename: |
| 39 | * --------- |
| 40 | * i2c_dual_sw.h |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * Maui_Software |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This file is intended for I2C DUAL driver. |
| 49 | * |
| 50 | * Author: |
| 51 | * ------- |
| 52 | * ------- |
| 53 | * |
| 54 | *============================================================================ |
| 55 | * HISTORY |
| 56 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 57 | *------------------------------------------------------------------------------ |
| 58 | * removed! |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * |
| 62 | * removed! |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * removed! |
| 73 | * |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * removed! |
| 77 | * |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * removed! |
| 81 | * |
| 82 | * removed! |
| 83 | * removed! |
| 84 | * removed! |
| 85 | * |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * removed! |
| 89 | * |
| 90 | * removed! |
| 91 | * removed! |
| 92 | * removed! |
| 93 | * |
| 94 | * removed! |
| 95 | * removed! |
| 96 | * removed! |
| 97 | * |
| 98 | * removed! |
| 99 | * removed! |
| 100 | * removed! |
| 101 | * |
| 102 | * removed! |
| 103 | * removed! |
| 104 | * removed! |
| 105 | * |
| 106 | *------------------------------------------------------------------------------ |
| 107 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 108 | *============================================================================ |
| 109 | ****************************************************************************/ |
| 110 | |
| 111 | #ifndef __I2C_DUAL_SW_H__ |
| 112 | #define __I2C_DUAL_SW_H__ |
| 113 | |
| 114 | |
| 115 | // MoDIS parser skip start |
| 116 | // The following are private APIs |
| 117 | // I2C DUAL driver is only used by PMIC6326 for now, NOT exported for other owners |
| 118 | |
| 119 | // #define MEASURE_I2C_DUAL_PERIOD |
| 120 | //#define I2C_DUAL_AP_MD_TEST |
| 121 | |
| 122 | #define I2C_DUAL_CHANNEL1 1 |
| 123 | #define I2C_DUAL_CHANNEL2 2 |
| 124 | #define I2C_DUAL_READ 0 |
| 125 | #define I2C_DUAL_WRITE 1 |
| 126 | |
| 127 | #define I2C_CLK_RATE 16250//13000 |
| 128 | |
| 129 | #define MAX_ST_MODE_SPEED 100 /* khz */ |
| 130 | #define MAX_FS_MODE_SPEED 1000 /* khz */ |
| 131 | #define MAX_HS_MODE_SPEED 3400 /* khz */ |
| 132 | |
| 133 | #define MAX_SAMPLE_CNT_DIV 8 |
| 134 | #define MAX_STEP_CNT_DIV 64 |
| 135 | #define MAX_HS_STEP_CNT_DIV 8 |
| 136 | |
| 137 | typedef enum { |
| 138 | ST_MODE, |
| 139 | FS_MODE, |
| 140 | HS_MODE, |
| 141 | } I2C_SPD_MODE; |
| 142 | |
| 143 | #if defined(MT6326) |
| 144 | kal_bool pmic6326_reg_write(kal_uint8 reg, kal_uint8 val); |
| 145 | kal_bool pmic6326_reg_read(kal_uint8 reg, kal_uint8 *pval); |
| 146 | |
| 147 | kal_bool pmic6326_reg_write_intr(kal_uint8 reg, kal_uint8 val); |
| 148 | kal_bool pmic6326_reg_read_intr(kal_uint8 reg, kal_uint8 *pval); |
| 149 | |
| 150 | kal_bool pmic6326_reg_write_polling(kal_uint8 reg, kal_uint8 val); |
| 151 | kal_bool pmic6326_reg_read_polling(kal_uint8 reg, kal_uint8 *pval); |
| 152 | |
| 153 | kal_bool pmic6326_reg_write_fast(kal_uint8 reg, kal_uint8 val); |
| 154 | kal_bool pmic6326_reg_read_fast(kal_uint8 reg, kal_uint8 *pval); |
| 155 | |
| 156 | kal_bool pmic6326_ch2_reg_write(kal_uint8 reg, kal_uint8 val); |
| 157 | kal_bool pmic6326_ch2_reg_read(kal_uint8 reg, kal_uint8 *pval); |
| 158 | |
| 159 | kal_bool pmic6326_ch2_reg_write_intr(kal_uint8 reg, kal_uint8 val); |
| 160 | kal_bool pmic6326_ch2_reg_read_intr(kal_uint8 reg, kal_uint8 *pval); |
| 161 | |
| 162 | kal_bool pmic6326_ch2_reg_write_polling(kal_uint8 reg, kal_uint8 val); |
| 163 | kal_bool pmic6326_ch2_reg_read_polling(kal_uint8 reg, kal_uint8 *pval); |
| 164 | |
| 165 | kal_bool pmic6326_ch2_reg_write_fast(kal_uint8 reg, kal_uint8 val); |
| 166 | kal_bool pmic6326_ch2_reg_read_fast(kal_uint8 reg, kal_uint8 *pval); |
| 167 | |
| 168 | #elif (defined(MT6329) || defined(MT6327)) |
| 169 | #define PMIC_BANK0 0 |
| 170 | #define PMIC_BANK1 1 |
| 171 | |
| 172 | #if defined(MEASURE_I2C_DUAL_PERIOD) |
| 173 | extern kal_uint32 i2c_dual_time1; |
| 174 | extern kal_uint32 i2c_dual_time2; |
| 175 | extern kal_uint32 i2c_dual_time3; |
| 176 | #endif |
| 177 | |
| 178 | kal_bool pmic6329_reg_write(kal_uint8 reg, kal_uint8 val, kal_uint32 bank); |
| 179 | kal_bool pmic6329_reg_read(kal_uint8 reg, kal_uint8 *pval, kal_uint32 bank); |
| 180 | |
| 181 | kal_bool pmic6329_reg_write_intr(kal_uint8 reg, kal_uint8 val, kal_uint32 bank); |
| 182 | kal_bool pmic6329_reg_read_intr(kal_uint8 reg, kal_uint8 *pval, kal_uint32 bank); |
| 183 | |
| 184 | kal_bool pmic6329_reg_write_polling(kal_uint8 reg, kal_uint8 val, kal_uint32 bank); |
| 185 | kal_bool pmic6329_reg_read_polling(kal_uint8 reg, kal_uint8 *pval, kal_uint32 bank); |
| 186 | |
| 187 | kal_bool pmic6329_reg_write_fast(kal_uint8 reg, kal_uint8 val, kal_uint32 bank); |
| 188 | kal_bool pmic6329_reg_read_fast(kal_uint8 reg, kal_uint8 *pval, kal_uint32 bank); |
| 189 | |
| 190 | kal_bool pmic6329_ch2_reg_write(kal_uint8 reg, kal_uint8 val, kal_uint32 bank); |
| 191 | kal_bool pmic6329_ch2_reg_read(kal_uint8 reg, kal_uint8 *pval, kal_uint32 bank); |
| 192 | |
| 193 | kal_bool pmic6329_ch2_reg_write_intr(kal_uint8 reg, kal_uint8 val, kal_uint32 bank); |
| 194 | kal_bool pmic6329_ch2_reg_read_intr(kal_uint8 reg, kal_uint8 *pval, kal_uint32 bank); |
| 195 | |
| 196 | kal_bool pmic6329_ch2_reg_write_polling(kal_uint8 reg, kal_uint8 val, kal_uint32 bank); |
| 197 | kal_bool pmic6329_ch2_reg_read_polling(kal_uint8 reg, kal_uint8 *pval, kal_uint32 bank); |
| 198 | |
| 199 | kal_bool pmic6329_ch2_reg_write_fast(kal_uint8 reg, kal_uint8 val, kal_uint32 bank); |
| 200 | kal_bool pmic6329_ch2_reg_read_fast(kal_uint8 reg, kal_uint8 *pval, kal_uint32 bank); |
| 201 | |
| 202 | |
| 203 | //============================================================================== |
| 204 | // I2C Exported Function |
| 205 | //============================================================================== |
| 206 | extern void i2c_v1_set_speed (unsigned long clock, I2C_SPD_MODE mode, unsigned long khz); |
| 207 | extern void i2c_dual_ap_md_test(void); |
| 208 | extern kal_bool i2c_dual_polling_trans_comp(kal_uint32 channel); |
| 209 | #endif // End of #if defined(MT6326) |
| 210 | // MoDIS parser skip end |
| 211 | |
| 212 | #endif // #ifndef __I2C_DUAL_SW_H__ |
| 213 | |