summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx31/gigabeat-s/mc13783-gigabeat-s.c
blob: 6d992388f295cb3c7ae8fdc612eba019c37c49b0 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (c) 2008 by Michael Sevakis
 *
 * Gigabeat S MC13783 event descriptions
 *
 * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/
#include "config.h"
#include "system.h"
#include "spi-imx31.h"
#include "mc13783.h"
#include "mc13783-target.h"
#include "adc-target.h"
#include "button-target.h"
#include "usb-target.h"
#include "power-gigabeat-s.h"
#include "powermgmt-target.h"

/* Gigabeat S mc13783 serial interface node. */

/* This is all based on communicating with the MC13783 PMU which is on 
 * CSPI2 with the chip select at 0. The LCD controller resides on
 * CSPI3 cs1, but we have no idea how to communicate to it */
struct spi_node mc13783_spi =
{
    CSPI2_NUM,                     /* CSPI module 2 */
    CSPI_CONREG_CHIP_SELECT_SS0 |  /* Chip select 0 */
    CSPI_CONREG_DRCTL_DONT_CARE |  /* Don't care about CSPI_RDY */
    CSPI_CONREG_DATA_RATE_DIV_32 | /* Clock = IPG_CLK/32 = 2,062,500Hz. */
    CSPI_BITCOUNT(32-1) |          /* All 32 bits are to be transferred */
    CSPI_CONREG_SSPOL |            /* SS active high */
    CSPI_CONREG_SSCTL |            /* Negate SS between SPI bursts */
    CSPI_CONREG_MODE,              /* Master mode */
    0,                             /* SPI clock - no wait states */
};


/* Gigabeat S definitions for static MC13783 event registration */

const struct mc13783_event mc13783_events[MC13783_NUM_EVENTS] =
{
    [MC13783_ADCDONE_EVENT] = /* ADC conversion complete */
    {
        .int_id = MC13783_INT_ID_ADCDONE,
        .callback = adc_done,
    },
    [MC13783_ONOFD1_EVENT] = /* Power button */
    {
        .int_id = MC13783_INT_ID_ONOFD1,
        .callback = button_power_event,
    },
    [MC13783_SE1_EVENT] = /* Main charger detection */
    {
        .int_id = MC13783_INT_ID_SE1,
        .callback = charger_main_detect_event,
    },
    [MC13783_USB_EVENT] = /* USB insertion/USB charger detection */
    {
        .int_id = MC13783_INT_ID_USB,
        .callback = usb_connect_event,
    },
#ifdef HAVE_HEADPHONE_DETECTION
    [MC13783_ONOFD2_EVENT] = /* Headphone jack */
    {
        .int_id = MC13783_INT_ID_ONOFD2,
        .callback = headphone_detect_event,
    },
#endif
};