static int __init msp_usb_setup(void) { char *strp; char envstr[32]; struct platform_device *msp_devs[NUM_USB_DEVS]; unsigned int val; /* construct environment name usbmode */ /* set usbmode <host/device> as pmon environment var */ /* * Could this perhaps be integrated into the "features" env var? * Use the features key "U", and follow with "H" for host-mode, * "D" for device-mode. If it works for Ethernet, why not USB... * -- hammtrev, 2007/03/22 */ snprintf(&envstr[0], sizeof(envstr), "usbmode"); /* set default host mode */ val = 1; /* get environment string */ strp = prom_getenv(&envstr[0]); if (strp) { /* compare string */ if (!strcmp(strp, "device")) val = 0; } if (val) { #if defined(CONFIG_USB_EHCI_HCD) msp_devs[0] = &msp_usbhost0_device.dev; ppfinit("platform add USB HOST done %s.\n", msp_devs[0]->name); #else ppfinit("%s: echi_hcd not supported\n", __FILE__); #endif /* CONFIG_USB_EHCI_HCD */ } else { #if defined(CONFIG_USB_GADGET) /* get device mode structure */ msp_devs[0] = &msp_usbdev0_device.dev; ppfinit("platform add USB DEVICE done %s.\n" , msp_devs[0]->name); #else ppfinit("%s: usb_gadget not supported\n", __FILE__); #endif /* CONFIG_USB_GADGET */ } /* add device */ platform_add_devices(msp_devs, ARRAY_SIZE(msp_devs)); return 0; }
static int __init msp_usb_setup(void) { #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_GADGET) char *strp; char envstr[32]; unsigned int val = 0; int result = 0; /* * construct environment name usbmode * set usbmode <host/device> as pmon environment var */ snprintf((char *)&envstr[0], sizeof(envstr), "usbmode"); #if defined(CONFIG_USB_EHCI_HCD) /* default to host mode */ val = 1; #endif /* get environment string */ strp = prom_getenv((char *)&envstr[0]); if (strp) { if (!strcmp(strp, "device")) val = 0; } if (val) { #if defined(CONFIG_USB_EHCI_HCD) /* get host mode device */ msp_devs[0] = &msp_usbhost_device; ppfinit("platform add USB HOST done %s.\n", msp_devs[0]->name); result = platform_add_devices(msp_devs, ARRAY_SIZE (msp_devs)); #endif /* CONFIG_USB_EHCI_HCD */ } #if defined(CONFIG_USB_GADGET) else { /* get device mode structure */ msp_devs[0] = &msp_usbdev_device; ppfinit("platform add USB DEVICE done %s.\n", msp_devs[0]->name); result = platform_add_devices(msp_devs, ARRAY_SIZE (msp_devs)); } #endif /* CONFIG_USB_GADGET */ #endif /* CONFIG_USB_EHCI_HCD || CONFIG_USB_GADGET */ return result; }
void __init msp_serial_setup(void) { char *s; char *endp; struct uart_port up; unsigned int uartclk; memset(&up, 0, sizeof(up)); /* Check if clock was specified in environment */ s = prom_getenv("uartfreqhz"); if(!(s && *s && (uartclk = simple_strtoul(s, &endp, 10)) && *endp == 0)) uartclk = MSP_BASE_BAUD; ppfinit("UART clock set to %d\n", uartclk); /* Initialize first serial port */ up.mapbase = MSP_UART0_BASE; up.membase = ioremap_nocache(up.mapbase, MSP_UART_REG_LEN); up.irq = MSP_INT_UART0; up.uartclk = uartclk; up.regshift = 2; up.iotype = UPIO_MEM; up.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST; up.type = PORT_16550A; up.line = 0; up.serial_out = msp_serial_out; up.serial_in = msp_serial_in; up.handle_irq = msp_serial_handle_irq; up.private_data = kzalloc(sizeof(struct msp_uart_data), GFP_KERNEL); if (!up.private_data) { pr_err("failed to allocate uart private data\n"); return; } if (early_serial_setup(&up)) { kfree(up.private_data); pr_err("Early serial init of port 0 failed\n"); } /* Initialize the second serial port, if one exists */ switch (mips_machtype) { case MACH_MSP4200_EVAL: case MACH_MSP4200_GW: case MACH_MSP4200_FPGA: case MACH_MSP7120_EVAL: case MACH_MSP7120_GW: case MACH_MSP7120_FPGA: /* Enable UART1 on MSP4200 and MSP7120 */ *GPIO_CFG2_REG = 0x00002299; break; default: return; /* No second serial port, good-bye. */ } up.mapbase = MSP_UART1_BASE; up.membase = ioremap_nocache(up.mapbase, MSP_UART_REG_LEN); up.irq = MSP_INT_UART1; up.line = 1; up.private_data = (void*)UART1_STATUS_REG; if (early_serial_setup(&up)) { kfree(up.private_data); pr_err("Early serial init of port 1 failed\n"); } }