Root/target/linux/ubicom32/files/arch/ubicom32/mach-common/usb.c

1/*
2 * arch/ubicom32/mach-common/ip5k_usb.c
3 * Ubicom32 architecture usb support.
4 *
5 * (C) Copyright 2009, Ubicom, Inc.
6 * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
7 * Author: Kevin Hilman
8 *
9 * This file is part of the Ubicom32 Linux Kernel Port.
10 *
11 * The Ubicom32 Linux Kernel Port is free software: you can
12 * redistribute it and/or modify it under the terms of the GNU General
13 * Public License as published by the Free Software Foundation, either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
17 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
18 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 * See the GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with the Ubicom32 Linux Kernel Port. If not,
23 * see <http://www.gnu.org/licenses/>.
24 *
25 * Ubicom32 implementation derived from (with many thanks):
26 * arch/m68knommu
27 * arch/blackfin
28 * arch/parisc
29 */
30
31#include <linux/types.h>
32#include <linux/errno.h>
33#include <linux/delay.h>
34#include <linux/platform_device.h>
35#include <linux/dma-mapping.h>
36#include <linux/usb/musb.h>
37#include <asm/devtree.h>
38#include <asm/ip5000.h>
39#include "usb_tio.h"
40
41struct usbtionode *unode = NULL;
42
43static struct resource usb_resources[] = {
44    [0] = {
45        .start = RJ + 0x800,
46        .end = RJ + 0x1000,
47        .flags = IORESOURCE_MEM,
48    },
49    [1] = { /* general IRQ */
50        .start = 1, /* this is a dummy value, the real irq number is passed from kernel_setup_param */
51        .flags = IORESOURCE_IRQ,
52    },
53};
54
55
56static struct musb_hdrc_eps_bits musb_eps[] = {
57    { "ep1_tx", 4, },
58    { "ep1_rx", 4, },
59    { "ep2_tx", 10, },
60    { "ep2_rx", 10, },
61    { "ep3_tx", 9, },
62    { "ep3_rx", 9, },
63    { "ep4_tx", 9, },
64    { "ep4_rx", 9, },
65    { "ep5_tx", 6, },
66    { "ep5_rx", 6, },
67};
68
69static struct musb_hdrc_config musb_config = {
70    .multipoint = true,
71    .dyn_fifo = false,
72    .soft_con = true,
73    .dma = false,
74
75    .num_eps = 6,
76    .dma_channels = 0,
77    .ram_bits = 0,
78    .eps_bits = musb_eps,
79};
80
81static struct musb_hdrc_platform_data usb_data = {
82#ifdef CONFIG_USB_MUSB_OTG
83    .mode = MUSB_OTG,
84#else
85#ifdef CONFIG_USB_MUSB_HDRC_HCD
86    .mode = MUSB_HOST,
87#else
88#ifdef CONFIG_USB_GADGET_MUSB_HDRC
89    .mode = MUSB_PERIPHERAL,
90#endif
91#endif
92#endif
93    .clock = NULL,
94    .set_clock = NULL,
95    .config = &musb_config,
96};
97
98static struct platform_device musb_device = {
99    .name = "musb_hdrc",
100    .id = 0,
101    .dev = {
102        .platform_data = &usb_data,
103        .dma_mask = NULL,
104        .coherent_dma_mask = 0,
105    },
106    .resource = usb_resources,
107    .num_resources = ARRAY_SIZE(usb_resources),
108};
109
110struct usbtio_node *usb_node = NULL;
111void ubi32_usb_init(void)
112{
113    /*
114     * See if the usbtio is in the device tree.
115     */
116    usb_node = (struct usbtio_node *)devtree_find_node("usbtio");
117    if (!usb_node) {
118        printk(KERN_WARNING "usb init failed\n");
119        return;
120    }
121
122    usb_resources[1].start = usb_node->dn.recvirq;
123    if (platform_device_register(&musb_device) < 0) {
124        printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
125        return;
126    }
127}
128
129void ubi32_usb_int_clr(void)
130{
131        UBICOM32_IO_PORT(RJ)->int_clr = (1 << 3);
132}
133

Archive Download this file



interactive