blob: 895bf37f2b567c39c2071711a8504abcdb45c6f7 [file] [log] [blame]
Jonathan Gordon139f9f22006-10-30 08:56:06 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Linus Nielsen Feltzing
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Jonathan Gordon139f9f22006-10-30 08:56:06 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22#include <stdbool.h>
23#include "cpu.h"
24#include "system.h"
25#include "kernel.h"
Dave Chapman16723502007-09-04 08:03:07 +000026#include "usb.h"
Jonathan Gordon139f9f22006-10-30 08:56:06 +000027
28void usb_init_device(void)
29{
30 or_l(0x00000080, &GPIO1_FUNCTION); /* GPIO39 is the USB detect input */
31 /* ISD300 3.3V ON */
32 or_l(8,&GPIO1_FUNCTION);
33 or_l(8,&GPIO1_OUT);
34 or_l(8,&GPIO1_ENABLE);
35
36 /* Tristate the SCK/SDA to the ISD300 config EEPROM */
37 and_l(~0x03000000, &GPIO_ENABLE);
38 or_l(0x03000000, &GPIO_FUNCTION);
39}
40
Dave Chapman16723502007-09-04 08:03:07 +000041int usb_detect(void)
Jonathan Gordon139f9f22006-10-30 08:56:06 +000042{
Dave Chapman16723502007-09-04 08:03:07 +000043 return (GPIO1_READ & 0x80) ? USB_INSERTED : USB_EXTRACTED;
Jonathan Gordon139f9f22006-10-30 08:56:06 +000044}
45
46void usb_enable(bool on)
47{
48 if(on)
49 {
50 /* Power on the Cypress chip */
51 and_l(~0x00000008,&GPIO1_OUT);
52 sleep(2);
53 }
54 else
55 {
56 /* Power off the Cypress chip */
57 or_l(0x00000008,&GPIO1_OUT);
58 }
59}