Jonathan Gordon | 139f9f2 | 2006-10-30 08:56:06 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2006 by Linus Nielsen Feltzing |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 12 | * 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 Gordon | 139f9f2 | 2006-10-30 08:56:06 +0000 | [diff] [blame] | 16 | * |
| 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 Chapman | 1672350 | 2007-09-04 08:03:07 +0000 | [diff] [blame] | 26 | #include "usb.h" |
Jonathan Gordon | 139f9f2 | 2006-10-30 08:56:06 +0000 | [diff] [blame] | 27 | |
| 28 | void 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 Chapman | 1672350 | 2007-09-04 08:03:07 +0000 | [diff] [blame] | 41 | int usb_detect(void) |
Jonathan Gordon | 139f9f2 | 2006-10-30 08:56:06 +0000 | [diff] [blame] | 42 | { |
Dave Chapman | 1672350 | 2007-09-04 08:03:07 +0000 | [diff] [blame] | 43 | return (GPIO1_READ & 0x80) ? USB_INSERTED : USB_EXTRACTED; |
Jonathan Gordon | 139f9f2 | 2006-10-30 08:56:06 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | void 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 | } |