1*485fe151Srin /* $NetBSD: obs600_autoconf.c,v 1.12 2021/03/30 04:41:30 rin Exp $ */
2325b8e82Skiyohara
3325b8e82Skiyohara /*
4325b8e82Skiyohara * Copyright 2004 Shigeyuki Fukushima.
5325b8e82Skiyohara * All rights reserved.
6325b8e82Skiyohara *
7325b8e82Skiyohara * Written by Shigeyuki Fukushima for The NetBSD Project.
8325b8e82Skiyohara *
9325b8e82Skiyohara * Redistribution and use in source and binary forms, with or without
10325b8e82Skiyohara * modification, are permitted provided that the following conditions
11325b8e82Skiyohara * are met:
12325b8e82Skiyohara * 1. Redistributions of source code must retain the above copyright
13325b8e82Skiyohara * notice, this list of conditions and the following disclaimer.
14325b8e82Skiyohara * 2. Redistributions in binary form must reproduce the above
15325b8e82Skiyohara * copyright notice, this list of conditions and the following
16325b8e82Skiyohara * disclaimer in the documentation and/or other materials provided
17325b8e82Skiyohara * with the distribution.
18325b8e82Skiyohara * 3. The name of the author may not be used to endorse or promote
19325b8e82Skiyohara * products derived from this software without specific prior
20325b8e82Skiyohara * written permission.
21325b8e82Skiyohara *
22325b8e82Skiyohara * THIS SOFTWARE IS PROVIDED THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23325b8e82Skiyohara * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24325b8e82Skiyohara * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25325b8e82Skiyohara * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
26325b8e82Skiyohara * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27325b8e82Skiyohara * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28325b8e82Skiyohara * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29325b8e82Skiyohara * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30325b8e82Skiyohara * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31325b8e82Skiyohara * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
32325b8e82Skiyohara * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
33325b8e82Skiyohara * DAMAGE.
34325b8e82Skiyohara */
35325b8e82Skiyohara #include <sys/cdefs.h>
36*485fe151Srin __KERNEL_RCSID(0, "$NetBSD: obs600_autoconf.c,v 1.12 2021/03/30 04:41:30 rin Exp $");
37a1cb7359Skiyohara
38a1cb7359Skiyohara #include "dwctwo.h"
39325b8e82Skiyohara
40*485fe151Srin #include <sys/param.h>
41325b8e82Skiyohara #include <sys/device.h>
4251a2be50Smatt #include <sys/intr.h>
43*485fe151Srin #include <sys/systm.h>
44325b8e82Skiyohara
45325b8e82Skiyohara #include <machine/obs600.h>
46325b8e82Skiyohara
47325b8e82Skiyohara #include <powerpc/ibm4xx/cpu.h>
48325b8e82Skiyohara #include <powerpc/ibm4xx/dcr4xx.h>
49325b8e82Skiyohara
50a1cb7359Skiyohara #if NDWCTWO > 0
51a1cb7359Skiyohara #include <dev/usb/usb.h>
52a1cb7359Skiyohara #include <dev/usb/usbdi.h>
53a1cb7359Skiyohara #include <dev/usb/usbdivar.h>
54a1cb7359Skiyohara
55a1cb7359Skiyohara #include <dwc2/dwc2.h>
56085368d8Smsaitoh #include <dwc2/dwc2var.h>
57a1cb7359Skiyohara #include "dwc2_core.h"
58a1cb7359Skiyohara
59a1cb7359Skiyohara /* This parameters was set from u-boot. */
60a1cb7359Skiyohara static struct dwc2_core_params dwctwo_obs600_params = {
61a1cb7359Skiyohara .otg_cap = 0, /* HNP/SRP capable */
62a1cb7359Skiyohara .otg_ver = 0, /* 1.3 */
63a1cb7359Skiyohara .dma_enable = 1,
64a1cb7359Skiyohara .dma_desc_enable = 0,
65a1cb7359Skiyohara .speed = 0, /* High Speed */
66a1cb7359Skiyohara .enable_dynamic_fifo = 1,
67a1cb7359Skiyohara .en_multiple_tx_fifo = 0,
68a1cb7359Skiyohara .host_rx_fifo_size = 531, /* 531 DWORDs */
69a1cb7359Skiyohara .host_nperio_tx_fifo_size = 256, /* 256 DWORDs */
70a1cb7359Skiyohara .host_perio_tx_fifo_size = 256, /* 256 DWORDs */
71a1cb7359Skiyohara .max_transfer_size = 524287,
72a1cb7359Skiyohara .max_packet_count = 1023,
73a1cb7359Skiyohara .host_channels = 4,
74a1cb7359Skiyohara .phy_type = 2, /* ULPI */
75a1cb7359Skiyohara .phy_utmi_width = 8, /* 8 bits */
76a1cb7359Skiyohara .phy_ulpi_ddr = 0, /* Single */
77a1cb7359Skiyohara .phy_ulpi_ext_vbus = 0,
78a1cb7359Skiyohara .i2c_enable = 0,
79a1cb7359Skiyohara .ulpi_fs_ls = 0,
80a1cb7359Skiyohara .host_support_fs_ls_low_power = 0,
81a1cb7359Skiyohara .host_ls_low_power_phy_clk = 0, /* 48 MHz */
82a1cb7359Skiyohara .ts_dline = 0,
83a1cb7359Skiyohara .reload_ctl = 0,
84a1cb7359Skiyohara .ahbcfg = 0x10,
85a1cb7359Skiyohara .uframe_sched = 1,
86a1cb7359Skiyohara };
87a1cb7359Skiyohara #endif
88a1cb7359Skiyohara
89325b8e82Skiyohara
90325b8e82Skiyohara /*
91325b8e82Skiyohara * Determine device configuration for a machine.
92325b8e82Skiyohara */
93325b8e82Skiyohara void
cpu_configure(void)94325b8e82Skiyohara cpu_configure(void)
95325b8e82Skiyohara {
96325b8e82Skiyohara
97325b8e82Skiyohara /* Initialize intr and add UICs */
98325b8e82Skiyohara intr_init();
99dba36e03Smatt pic_add(&pic_uic1);
100dba36e03Smatt pic_add(&pic_uic2);
101325b8e82Skiyohara
102325b8e82Skiyohara /* Make sure that timers run at CPU frequency */
103325b8e82Skiyohara mtdcr(DCR_CPC0_CR1, mfdcr(DCR_CPC0_CR1) & ~CPC0_CR1_CETE);
104325b8e82Skiyohara
105325b8e82Skiyohara if (config_rootfound("plb", NULL) == NULL)
106325b8e82Skiyohara panic("configure: mainbus not configured");
107325b8e82Skiyohara
108b8137ad4Skiyohara pic_finish_setup();
109b8137ad4Skiyohara
1101f194d9aSrin genppc_cpu_configure();
111325b8e82Skiyohara }
112325b8e82Skiyohara
11351a2be50Smatt void
device_register(device_t dev,void * aux)11451a2be50Smatt device_register(device_t dev, void *aux)
115325b8e82Skiyohara {
116325b8e82Skiyohara
117a1cb7359Skiyohara #if NDWCTWO > 0
118a1cb7359Skiyohara if (device_is_a(dev, "dwctwo")) {
119a1cb7359Skiyohara prop_dictionary_t dict = device_properties(dev);
120a1cb7359Skiyohara
121a1cb7359Skiyohara prop_dictionary_set_uint32(dict, "params",
122a1cb7359Skiyohara (uint32_t)&dwctwo_obs600_params);
123a1cb7359Skiyohara return;
124a1cb7359Skiyohara }
125a1cb7359Skiyohara #endif
126a1cb7359Skiyohara
12736cc5934Srin ibm4xx_device_register(dev, aux, OBS600_COM_FREQ);
128325b8e82Skiyohara }
129