Linus Nielsen Feltzing | 8f18680 | 2006-03-22 11:06:45 +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. |
Linus Nielsen Feltzing | 8f18680 | 2006-03-22 11:06:45 +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" |
Dave Chapman | 1672350 | 2007-09-04 08:03:07 +0000 | [diff] [blame] | 25 | #include "usb.h" |
Linus Nielsen Feltzing | 8f18680 | 2006-03-22 11:06:45 +0000 | [diff] [blame] | 26 | |
| 27 | void usb_init_device(void) |
| 28 | { |
Linus Nielsen Feltzing | d543bd4 | 2006-10-18 20:56:29 +0000 | [diff] [blame] | 29 | or_l(0x00800010, &GPIO_OUT); /* RESET deasserted, VBUS powered */ |
Linus Nielsen Feltzing | 8f18680 | 2006-03-22 11:06:45 +0000 | [diff] [blame] | 30 | or_l(0x00800010, &GPIO_ENABLE); |
Linus Nielsen Feltzing | d543bd4 | 2006-10-18 20:56:29 +0000 | [diff] [blame] | 31 | or_l(0x00800010, &GPIO_FUNCTION); |
Linus Nielsen Feltzing | 8f18680 | 2006-03-22 11:06:45 +0000 | [diff] [blame] | 32 | |
| 33 | or_l(0x00800000, &GPIO1_FUNCTION); /* USB detect */ |
| 34 | } |
| 35 | |
Dave Chapman | 1672350 | 2007-09-04 08:03:07 +0000 | [diff] [blame] | 36 | int usb_detect(void) |
Linus Nielsen Feltzing | 8f18680 | 2006-03-22 11:06:45 +0000 | [diff] [blame] | 37 | { |
Dave Chapman | 1672350 | 2007-09-04 08:03:07 +0000 | [diff] [blame] | 38 | return (GPIO1_READ & 0x00800000) ? USB_INSERTED : USB_EXTRACTED; |
Linus Nielsen Feltzing | 8f18680 | 2006-03-22 11:06:45 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | void usb_enable(bool on) |
| 42 | { |
| 43 | if(on) { |
| 44 | or_l(0x00000008, &GPIO1_OUT); |
| 45 | } else { |
| 46 | and_l(~0x00000008, &GPIO1_OUT); |
| 47 | } |
| 48 | } |