summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/odm_kit/adaptations/pmu/pcf50626/ds2482_bridge.c
blob: 5070a0a18eeb821950ed95bf3f6cf8f546b80e7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (c) 2009 NVIDIA Corporation.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include "ds2482_bridge.h"
#include "pcf50626_i2c.h"
#include "ds2482_i2c.h"
#include "pcf50626_reg.h"
#include "ds2482_reg.h"

NvBool 
Ds2482Setup(NvOdmPmuDeviceHandle hDevice)
{
    NvU8 data = 0;
    
    // One wire I2C bridge
    //Device Reset Status
    if (!Ds2482OWI2cRead8(hDevice, DS2482_DEVICE_RESET, &data))
        return NV_FALSE;
    //NVODMPMU_PRINTF(("Device Reset reg 0x%02x = 0x%02x\n", DS2482_DEVICE_RESET, data));

    //1-Wire Reset Status
    if (!Ds2482OWI2cRead8(hDevice, DS2482_1WIRE_RESET, &data))
        return NV_FALSE;
    //NVODMPMU_PRINTF(("1-Wire Reset reg 0x%02x = 0x%02x\n", DS2482_1WIRE_RESET, data));

    while(1)
    {
        if (!Ds2482OWI2cWrite8(hDevice, DS2482_READ_DATA_REG_ADDR, DS2482_DEVICE_RESET))
            return NV_FALSE;

        if (!Ds2482OWI2cRead8(hDevice, DS2482_READ_DATA_REG_ADDR, &data))
            return NV_FALSE;

        if (!(data & 0x01))
            break;
    }


    return NV_TRUE;
}