i.MX31/Gigabeat S minor cleaning: Make HW access more obvious in places I forgot...
[kugel-rb.git] / firmware / target / arm / imx31 / gigabeat-s / mc13783-gigabeat-s.c
blobe0745a5b8bdc3e5607309d673e284fa7c778cb59
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (c) 2008 by Michael Sevakis
12 * Gigabeat S MC13783 event descriptions
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
23 #include "config.h"
24 #include "system.h"
25 #include "spi-imx31.h"
26 #include "mc13783.h"
27 #include "mc13783-target.h"
28 #include "adc-target.h"
29 #include "button-target.h"
30 #include "usb-target.h"
31 #include "power-gigabeat-s.h"
32 #include "powermgmt-target.h"
34 /* Gigabeat S mc13783 serial interface node. */
36 /* This is all based on communicating with the MC13783 PMU which is on
37 * CSPI2 with the chip select at 0. The LCD controller resides on
38 * CSPI3 cs1, but we have no idea how to communicate to it */
39 struct spi_node mc13783_spi =
41 CSPI2_NUM, /* CSPI module 2 */
42 CSPI_CONREG_CHIP_SELECT_SS0 | /* Chip select 0 */
43 CSPI_CONREG_DRCTL_DONT_CARE | /* Don't care about CSPI_RDY */
44 CSPI_CONREG_DATA_RATE_DIV_32 | /* Clock = IPG_CLK/32 = 2,062,500Hz. */
45 CSPI_BITCOUNT(32-1) | /* All 32 bits are to be transferred */
46 CSPI_CONREG_SSPOL | /* SS active high */
47 CSPI_CONREG_SSCTL | /* Negate SS between SPI bursts */
48 CSPI_CONREG_MODE, /* Master mode */
49 0, /* SPI clock - no wait states */
53 /* Gigabeat S definitions for static MC13783 event registration */
55 const struct mc13783_event mc13783_events[MC13783_NUM_EVENTS] =
57 [MC13783_ADCDONE_EVENT] = /* ADC conversion complete */
59 .set = MC13783_EVENT_SET0,
60 .mask = MC13783_ADCDONEM,
61 .callback = adc_done,
63 [MC13783_ONOFD1_EVENT] = /* Power button */
65 .set = MC13783_EVENT_SET1,
66 .mask = MC13783_ONOFD1M,
67 .callback = button_power_event,
69 [MC13783_SE1_EVENT] = /* Main charger detection */
71 .set = MC13783_EVENT_SET0,
72 .mask = MC13783_SE1M,
73 .callback = charger_main_detect_event,
75 [MC13783_USB_EVENT] = /* USB insertion/USB charger detection */
77 .set = MC13783_EVENT_SET0,
78 .mask = MC13783_USBM,
79 .callback = usb_connect_event,
81 #ifdef HAVE_HEADPHONE_DETECTION
82 [MC13783_ONOFD2_EVENT] = /* Headphone jack */
84 .set = MC13783_EVENT_SET1,
85 .mask = MC13783_ONOFD2M,
86 .callback = headphone_detect_event,
88 #endif