1 /* $NetBSD: obs600_autoconf.c,v 1.7 2013/11/21 13:52:27 kiyohara 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.7 2013/11/21 13:52:27 kiyohara 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_core.h" 59 60 /* This parameters was set from u-boot. */ 61 static struct dwc2_core_params dwctwo_obs600_params = { 62 .otg_cap = 0, /* HNP/SRP capable */ 63 .otg_ver = 0, /* 1.3 */ 64 .dma_enable = 1, 65 .dma_desc_enable = 0, 66 .speed = 0, /* High Speed */ 67 .enable_dynamic_fifo = 1, 68 .en_multiple_tx_fifo = 0, 69 .host_rx_fifo_size = 531, /* 531 DWORDs */ 70 .host_nperio_tx_fifo_size = 256, /* 256 DWORDs */ 71 .host_perio_tx_fifo_size = 256, /* 256 DWORDs */ 72 .max_transfer_size = 524287, 73 .max_packet_count = 1023, 74 .host_channels = 4, 75 .phy_type = 2, /* ULPI */ 76 .phy_utmi_width = 8, /* 8 bits */ 77 .phy_ulpi_ddr = 0, /* Single */ 78 .phy_ulpi_ext_vbus = 0, 79 .i2c_enable = 0, 80 .ulpi_fs_ls = 0, 81 .host_support_fs_ls_low_power = 0, 82 .host_ls_low_power_phy_clk = 0, /* 48 MHz */ 83 .ts_dline = 0, 84 .reload_ctl = 0, 85 .ahbcfg = 0x10, 86 .uframe_sched = 1, 87 }; 88 #endif 89 90 91 /* 92 * Determine device configuration for a machine. 93 */ 94 void 95 cpu_configure(void) 96 { 97 98 /* Initialize intr and add UICs */ 99 intr_init(); 100 pic_add(&pic_uic1); 101 pic_add(&pic_uic2); 102 103 calc_delayconst(); 104 105 /* Make sure that timers run at CPU frequency */ 106 mtdcr(DCR_CPC0_CR1, mfdcr(DCR_CPC0_CR1) & ~CPC0_CR1_CETE); 107 108 if (config_rootfound("plb", NULL) == NULL) 109 panic("configure: mainbus not configured"); 110 111 pic_finish_setup(); 112 113 printf("biomask %x netmask %x ttymask %x\n", 114 imask[IPL_BIO], imask[IPL_NET], imask[IPL_TTY]); 115 116 (void)spl0(); 117 } 118 119 void 120 device_register(device_t dev, void *aux) 121 { 122 123 #if NDWCTWO > 0 124 if (device_is_a(dev, "dwctwo")) { 125 prop_dictionary_t dict = device_properties(dev); 126 127 prop_dictionary_set_uint32(dict, "params", 128 (uint32_t)&dwctwo_obs600_params); 129 return; 130 } 131 #endif 132 133 obs405_device_register(dev, aux, OBS600_COM_FREQ); 134 } 135