obs600_autoconf.c revision 1.9
1/*	$NetBSD: obs600_autoconf.c,v 1.9 2021/03/02 07:21:01 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.9 2021/03/02 07:21:01 rin Exp $");
37
38#include "dwctwo.h"
39
40#include <sys/systm.h>
41#include <sys/device.h>
42#include <sys/cpu.h>
43#include <sys/intr.h>
44
45#include <machine/obs600.h>
46
47#include <powerpc/ibm4xx/cpu.h>
48#include <powerpc/ibm4xx/dcr4xx.h>
49
50#include <dev/ic/comreg.h>
51
52#if NDWCTWO > 0
53#include <dev/usb/usb.h>
54#include <dev/usb/usbdi.h>
55#include <dev/usb/usbdivar.h>
56
57#include <dwc2/dwc2.h>
58#include <dwc2/dwc2var.h>
59#include "dwc2_core.h"
60
61/* This parameters was set from u-boot. */
62static struct dwc2_core_params dwctwo_obs600_params = {
63	.otg_cap			= 0,	/* HNP/SRP capable */
64	.otg_ver			= 0,	/* 1.3 */
65	.dma_enable			= 1,
66	.dma_desc_enable		= 0,
67	.speed				= 0,	/* High Speed */
68	.enable_dynamic_fifo		= 1,
69	.en_multiple_tx_fifo		= 0,
70	.host_rx_fifo_size		= 531,	/* 531 DWORDs */
71	.host_nperio_tx_fifo_size	= 256,	/* 256 DWORDs */
72	.host_perio_tx_fifo_size	= 256,	/* 256 DWORDs */
73	.max_transfer_size		= 524287,
74	.max_packet_count		= 1023,
75	.host_channels			= 4,
76	.phy_type			= 2,	/* ULPI */
77	.phy_utmi_width			= 8,	/* 8 bits */
78	.phy_ulpi_ddr			= 0,	/* Single */
79	.phy_ulpi_ext_vbus		= 0,
80	.i2c_enable			= 0,
81	.ulpi_fs_ls			= 0,
82	.host_support_fs_ls_low_power	= 0,
83	.host_ls_low_power_phy_clk	= 0,	/* 48 MHz */
84	.ts_dline			= 0,
85	.reload_ctl			= 0,
86	.ahbcfg				= 0x10,
87	.uframe_sched			= 1,
88};
89#endif
90
91
92/*
93 * Determine device configuration for a machine.
94 */
95void
96cpu_configure(void)
97{
98
99	/* Initialize intr and add UICs */
100	intr_init();
101	pic_add(&pic_uic1);
102	pic_add(&pic_uic2);
103
104	calc_delayconst();
105
106	/* Make sure that timers run at CPU frequency */
107	mtdcr(DCR_CPC0_CR1, mfdcr(DCR_CPC0_CR1) & ~CPC0_CR1_CETE);
108
109	if (config_rootfound("plb", NULL) == NULL)
110		panic("configure: mainbus not configured");
111
112	pic_finish_setup();
113
114	genppc_cpu_configure();
115}
116
117void
118device_register(device_t dev, void *aux)
119{
120
121#if NDWCTWO > 0
122	if (device_is_a(dev, "dwctwo")) {
123		prop_dictionary_t dict = device_properties(dev);
124
125		prop_dictionary_set_uint32(dict, "params",
126		    (uint32_t)&dwctwo_obs600_params);
127		return;
128	}
129#endif
130
131	obs405_device_register(dev, aux, OBS600_COM_FREQ);
132}
133