obs600_autoconf.c revision 1.7
11.7Skiyohara/*	$NetBSD: obs600_autoconf.c,v 1.7 2013/11/21 13:52:27 kiyohara Exp $	*/
21.1Skiyohara
31.1Skiyohara/*
41.1Skiyohara * Copyright 2004 Shigeyuki Fukushima.
51.1Skiyohara * All rights reserved.
61.1Skiyohara *
71.1Skiyohara * Written by Shigeyuki Fukushima for The NetBSD Project.
81.1Skiyohara *
91.1Skiyohara * Redistribution and use in source and binary forms, with or without
101.1Skiyohara * modification, are permitted provided that the following conditions
111.1Skiyohara * are met:
121.1Skiyohara * 1. Redistributions of source code must retain the above copyright
131.1Skiyohara *    notice, this list of conditions and the following disclaimer.
141.1Skiyohara * 2. Redistributions in binary form must reproduce the above
151.1Skiyohara *    copyright notice, this list of conditions and the following
161.1Skiyohara *    disclaimer in the documentation and/or other materials provided
171.1Skiyohara *    with the distribution.
181.1Skiyohara * 3. The name of the author may not be used to endorse or promote
191.1Skiyohara *    products derived from this software without specific prior
201.1Skiyohara *    written permission.
211.1Skiyohara *
221.1Skiyohara * THIS SOFTWARE IS PROVIDED THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
231.1Skiyohara * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
241.1Skiyohara * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
251.1Skiyohara * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
261.1Skiyohara * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
271.1Skiyohara * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
281.1Skiyohara * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
291.1Skiyohara * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
301.1Skiyohara * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
311.1Skiyohara * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
321.1Skiyohara * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
331.1Skiyohara * DAMAGE.
341.1Skiyohara */
351.1Skiyohara#include <sys/cdefs.h>
361.7Skiyohara__KERNEL_RCSID(0, "$NetBSD: obs600_autoconf.c,v 1.7 2013/11/21 13:52:27 kiyohara Exp $");
371.7Skiyohara
381.7Skiyohara#include "dwctwo.h"
391.1Skiyohara
401.1Skiyohara#include <sys/systm.h>
411.1Skiyohara#include <sys/device.h>
421.3Smatt#include <sys/cpu.h>
431.3Smatt#include <sys/intr.h>
441.1Skiyohara
451.1Skiyohara#include <machine/obs600.h>
461.1Skiyohara
471.1Skiyohara#include <powerpc/ibm4xx/cpu.h>
481.1Skiyohara#include <powerpc/ibm4xx/dcr4xx.h>
491.1Skiyohara
501.1Skiyohara#include <dev/ic/comreg.h>
511.1Skiyohara
521.7Skiyohara#if NDWCTWO > 0
531.7Skiyohara#include <dev/usb/usb.h>
541.7Skiyohara#include <dev/usb/usbdi.h>
551.7Skiyohara#include <dev/usb/usbdivar.h>
561.7Skiyohara
571.7Skiyohara#include <dwc2/dwc2.h>
581.7Skiyohara#include "dwc2_core.h"
591.7Skiyohara
601.7Skiyohara/* This parameters was set from u-boot. */
611.7Skiyoharastatic struct dwc2_core_params dwctwo_obs600_params = {
621.7Skiyohara	.otg_cap			= 0,	/* HNP/SRP capable */
631.7Skiyohara	.otg_ver			= 0,	/* 1.3 */
641.7Skiyohara	.dma_enable			= 1,
651.7Skiyohara	.dma_desc_enable		= 0,
661.7Skiyohara	.speed				= 0,	/* High Speed */
671.7Skiyohara	.enable_dynamic_fifo		= 1,
681.7Skiyohara	.en_multiple_tx_fifo		= 0,
691.7Skiyohara	.host_rx_fifo_size		= 531,	/* 531 DWORDs */
701.7Skiyohara	.host_nperio_tx_fifo_size	= 256,	/* 256 DWORDs */
711.7Skiyohara	.host_perio_tx_fifo_size	= 256,	/* 256 DWORDs */
721.7Skiyohara	.max_transfer_size		= 524287,
731.7Skiyohara	.max_packet_count		= 1023,
741.7Skiyohara	.host_channels			= 4,
751.7Skiyohara	.phy_type			= 2,	/* ULPI */
761.7Skiyohara	.phy_utmi_width			= 8,	/* 8 bits */
771.7Skiyohara	.phy_ulpi_ddr			= 0,	/* Single */
781.7Skiyohara	.phy_ulpi_ext_vbus		= 0,
791.7Skiyohara	.i2c_enable			= 0,
801.7Skiyohara	.ulpi_fs_ls			= 0,
811.7Skiyohara	.host_support_fs_ls_low_power	= 0,
821.7Skiyohara	.host_ls_low_power_phy_clk	= 0,	/* 48 MHz */
831.7Skiyohara	.ts_dline			= 0,
841.7Skiyohara	.reload_ctl			= 0,
851.7Skiyohara	.ahbcfg				= 0x10,
861.7Skiyohara	.uframe_sched			= 1,
871.7Skiyohara};
881.7Skiyohara#endif
891.7Skiyohara
901.1Skiyohara
911.1Skiyohara/*
921.1Skiyohara * Determine device configuration for a machine.
931.1Skiyohara */
941.1Skiyoharavoid
951.1Skiyoharacpu_configure(void)
961.1Skiyohara{
971.1Skiyohara
981.1Skiyohara	/* Initialize intr and add UICs */
991.1Skiyohara	intr_init();
1001.4Smatt	pic_add(&pic_uic1);
1011.4Smatt	pic_add(&pic_uic2);
1021.1Skiyohara
1031.1Skiyohara	calc_delayconst();
1041.1Skiyohara
1051.1Skiyohara	/* Make sure that timers run at CPU frequency */
1061.1Skiyohara	mtdcr(DCR_CPC0_CR1, mfdcr(DCR_CPC0_CR1) & ~CPC0_CR1_CETE);
1071.1Skiyohara
1081.1Skiyohara	if (config_rootfound("plb", NULL) == NULL)
1091.1Skiyohara		panic("configure: mainbus not configured");
1101.1Skiyohara
1111.6Skiyohara	pic_finish_setup();
1121.6Skiyohara
1131.1Skiyohara	printf("biomask %x netmask %x ttymask %x\n",
1141.1Skiyohara	    imask[IPL_BIO], imask[IPL_NET], imask[IPL_TTY]);
1151.1Skiyohara
1161.1Skiyohara	(void)spl0();
1171.1Skiyohara}
1181.1Skiyohara
1191.3Smattvoid
1201.3Smattdevice_register(device_t dev, void *aux)
1211.1Skiyohara{
1221.1Skiyohara
1231.7Skiyohara#if NDWCTWO > 0
1241.7Skiyohara	if (device_is_a(dev, "dwctwo")) {
1251.7Skiyohara		prop_dictionary_t dict = device_properties(dev);
1261.7Skiyohara
1271.7Skiyohara		prop_dictionary_set_uint32(dict, "params",
1281.7Skiyohara		    (uint32_t)&dwctwo_obs600_params);
1291.7Skiyohara		return;
1301.7Skiyohara	}
1311.7Skiyohara#endif
1321.7Skiyohara
1331.1Skiyohara	obs405_device_register(dev, aux, OBS600_COM_FREQ);
1341.1Skiyohara}
135