1 /* $NetBSD: obs600_autoconf.c,v 1.12 2021/03/30 04:41:30 rin Exp $ */
2
3 /*
4 * Copyright 2004 Shigeyuki Fukushima.
5 * All rights reserved.
6 *
7 * Written by Shigeyuki Fukushima for The NetBSD Project.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * 3. The name of the author may not be used to endorse or promote
19 * products derived from this software without specific prior
20 * written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
32 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
33 * DAMAGE.
34 */
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD: obs600_autoconf.c,v 1.12 2021/03/30 04:41:30 rin Exp $");
37
38 #include "dwctwo.h"
39
40 #include <sys/param.h>
41 #include <sys/device.h>
42 #include <sys/intr.h>
43 #include <sys/systm.h>
44
45 #include <machine/obs600.h>
46
47 #include <powerpc/ibm4xx/cpu.h>
48 #include <powerpc/ibm4xx/dcr4xx.h>
49
50 #if NDWCTWO > 0
51 #include <dev/usb/usb.h>
52 #include <dev/usb/usbdi.h>
53 #include <dev/usb/usbdivar.h>
54
55 #include <dwc2/dwc2.h>
56 #include <dwc2/dwc2var.h>
57 #include "dwc2_core.h"
58
59 /* This parameters was set from u-boot. */
60 static struct dwc2_core_params dwctwo_obs600_params = {
61 .otg_cap = 0, /* HNP/SRP capable */
62 .otg_ver = 0, /* 1.3 */
63 .dma_enable = 1,
64 .dma_desc_enable = 0,
65 .speed = 0, /* High Speed */
66 .enable_dynamic_fifo = 1,
67 .en_multiple_tx_fifo = 0,
68 .host_rx_fifo_size = 531, /* 531 DWORDs */
69 .host_nperio_tx_fifo_size = 256, /* 256 DWORDs */
70 .host_perio_tx_fifo_size = 256, /* 256 DWORDs */
71 .max_transfer_size = 524287,
72 .max_packet_count = 1023,
73 .host_channels = 4,
74 .phy_type = 2, /* ULPI */
75 .phy_utmi_width = 8, /* 8 bits */
76 .phy_ulpi_ddr = 0, /* Single */
77 .phy_ulpi_ext_vbus = 0,
78 .i2c_enable = 0,
79 .ulpi_fs_ls = 0,
80 .host_support_fs_ls_low_power = 0,
81 .host_ls_low_power_phy_clk = 0, /* 48 MHz */
82 .ts_dline = 0,
83 .reload_ctl = 0,
84 .ahbcfg = 0x10,
85 .uframe_sched = 1,
86 };
87 #endif
88
89
90 /*
91 * Determine device configuration for a machine.
92 */
93 void
cpu_configure(void)94 cpu_configure(void)
95 {
96
97 /* Initialize intr and add UICs */
98 intr_init();
99 pic_add(&pic_uic1);
100 pic_add(&pic_uic2);
101
102 /* Make sure that timers run at CPU frequency */
103 mtdcr(DCR_CPC0_CR1, mfdcr(DCR_CPC0_CR1) & ~CPC0_CR1_CETE);
104
105 if (config_rootfound("plb", NULL) == NULL)
106 panic("configure: mainbus not configured");
107
108 pic_finish_setup();
109
110 genppc_cpu_configure();
111 }
112
113 void
device_register(device_t dev,void * aux)114 device_register(device_t dev, void *aux)
115 {
116
117 #if NDWCTWO > 0
118 if (device_is_a(dev, "dwctwo")) {
119 prop_dictionary_t dict = device_properties(dev);
120
121 prop_dictionary_set_uint32(dict, "params",
122 (uint32_t)&dwctwo_obs600_params);
123 return;
124 }
125 #endif
126
127 ibm4xx_device_register(dev, aux, OBS600_COM_FREQ);
128 }
129