Channagoud Kadabi | 5ccc308 | 2013-02-08 13:15:32 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of The Linux Foundation, Inc. nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #include <pm8x41_adc.h> |
| 31 | #include <debug.h> |
| 32 | |
| 33 | void adc_test() |
| 34 | { |
| 35 | uint32_t vadc_chan1; |
| 36 | uint32_t vadc_chan2; |
| 37 | uint16_t iusb = 3250000; |
| 38 | uint16_t ibat = 2500000; |
| 39 | uint16_t batt_id_chan = 49; |
| 40 | uint16_t vbat_sns_chan = 6; |
| 41 | |
| 42 | /* |
| 43 | * TEST: Read the voltage on batt_id & vbat_sns channels |
| 44 | */ |
| 45 | vadc_chan1 = pm8x41_adc_channel_read(batt_id_chan); |
| 46 | dprintf(INFO, "The channel [%ud] voltage is :%ud\n",batt_id_chan, vadc_chan1); |
| 47 | |
| 48 | vadc_chan2 = pm8x41_adc_channel_read(vbat_sns_chan); |
| 49 | dprintf(INFO, "The channel [%ud] voltage is :%ud\n",vbat_sns_chan, vadc_chan2); |
| 50 | |
| 51 | /* |
| 52 | * TEST: Set the IUSB & IBAT max values |
| 53 | */ |
| 54 | |
| 55 | if (!pm8x41_iusb_max_config(iusb)) |
| 56 | dprintf(INFO, "Iusb max current is set\n"); |
| 57 | |
| 58 | if (!pm8x41_ibat_max_config(ibat)) |
| 59 | dprintf(INFO, "Ibat max current is set\n"); |
| 60 | |
| 61 | } |