⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.c

📁 h内核
💻 C
📖 第 1 页 / 共 2 页
字号:
		iotable_init(omap730_io_desc, ARRAY_SIZE(omap730_io_desc));	}#endif#ifdef CONFIG_ARCH_OMAP1510	if (cpu_is_omap1510()) {		iotable_init(omap1510_io_desc, ARRAY_SIZE(omap1510_io_desc));	}#endif#if defined(CONFIG_ARCH_OMAP16XX)	if (cpu_is_omap1610() || cpu_is_omap1710()) {		iotable_init(omap1610_io_desc, ARRAY_SIZE(omap1610_io_desc));	}	if (cpu_is_omap5912()) {		iotable_init(omap5912_io_desc, ARRAY_SIZE(omap5912_io_desc));	}#endif	/* REVISIT: Refer to OMAP5910 Errata, Advisory SYS_1: "Timeout Abort	 * on a Posted Write in the TIPB Bridge".	 */	omap_writew(0x0, MPU_PUBLIC_TIPB_CNTL);	omap_writew(0x0, MPU_PRIVATE_TIPB_CNTL);	/* Must init clocks early to assure that timer interrupt works	 */	clk_init();}/* * This should only get called from board specific init */void omap_map_io(void){	if (!initialized)		_omap_map_io();}static inline unsigned int omap_serial_in(struct plat_serial8250_port *up,					  int offset){	offset <<= up->regshift;	return (unsigned int)__raw_readb(up->membase + offset);}static inline void omap_serial_outp(struct plat_serial8250_port *p, int offset,				    int value){	offset <<= p->regshift;	__raw_writeb(value, p->membase + offset);}/* * Internal UARTs need to be initialized for the 8250 autoconfig to work * properly. Note that the TX watermark initialization may not be needed * once the 8250.c watermark handling code is merged. */static void __init omap_serial_reset(struct plat_serial8250_port *p){	omap_serial_outp(p, UART_OMAP_MDR1, 0x07);	/* disable UART */	omap_serial_outp(p, UART_OMAP_SCR, 0x08);	/* TX watermark */	omap_serial_outp(p, UART_OMAP_MDR1, 0x00);	/* enable UART */	if (!cpu_is_omap1510()) {		omap_serial_outp(p, UART_OMAP_SYSC, 0x01);		while (!(omap_serial_in(p, UART_OMAP_SYSC) & 0x01));	}}static struct plat_serial8250_port serial_platform_data[] = {	{		.membase	= (char*)IO_ADDRESS(OMAP_UART1_BASE),		.mapbase	= (unsigned long)OMAP_UART1_BASE,		.irq		= INT_UART1,		.flags		= UPF_BOOT_AUTOCONF,		.iotype		= UPIO_MEM,		.regshift	= 2,		.uartclk	= OMAP16XX_BASE_BAUD * 16,	},	{		.membase	= (char*)IO_ADDRESS(OMAP_UART2_BASE),		.mapbase	= (unsigned long)OMAP_UART2_BASE,		.irq		= INT_UART2,		.flags		= UPF_BOOT_AUTOCONF,		.iotype		= UPIO_MEM,		.regshift	= 2,		.uartclk	= OMAP16XX_BASE_BAUD * 16,	},	{		.membase	= (char*)IO_ADDRESS(OMAP_UART3_BASE),		.mapbase	= (unsigned long)OMAP_UART3_BASE,		.irq		= INT_UART3,		.flags		= UPF_BOOT_AUTOCONF,		.iotype		= UPIO_MEM,		.regshift	= 2,		.uartclk	= OMAP16XX_BASE_BAUD * 16,	},	{ },};static struct platform_device serial_device = {	.name			= "serial8250",	.id			= 0,	.dev			= {		.platform_data	= serial_platform_data,	},};/* * Note that on Innovator-1510 UART2 pins conflict with USB2. * By default UART2 does not work on Innovator-1510 if you have * USB OHCI enabled. To use UART2, you must disable USB2 first. */void __init omap_serial_init(int ports[OMAP_MAX_NR_PORTS]){	int i;	if (cpu_is_omap730()) {		serial_platform_data[0].regshift = 0;		serial_platform_data[1].regshift = 0;		serial_platform_data[0].irq = INT_730_UART_MODEM_1;		serial_platform_data[1].irq = INT_730_UART_MODEM_IRDA_2;	}	if (cpu_is_omap1510()) {		serial_platform_data[0].uartclk = OMAP1510_BASE_BAUD * 16;		serial_platform_data[1].uartclk = OMAP1510_BASE_BAUD * 16;		serial_platform_data[2].uartclk = OMAP1510_BASE_BAUD * 16;	}	for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {		unsigned char reg;		if (ports[i] == 0) {			serial_platform_data[i].membase = 0;			serial_platform_data[i].mapbase = 0;			continue;		}		switch (i) {		case 0:			if (cpu_is_omap1510()) {				omap_cfg_reg(UART1_TX);				omap_cfg_reg(UART1_RTS);				if (machine_is_omap_innovator()) {					reg = fpga_read(OMAP1510_FPGA_POWER);					reg |= OMAP1510_FPGA_PCR_COM1_EN;					fpga_write(reg, OMAP1510_FPGA_POWER);					udelay(10);				}			}			break;		case 1:			if (cpu_is_omap1510()) {				omap_cfg_reg(UART2_TX);				omap_cfg_reg(UART2_RTS);				if (machine_is_omap_innovator()) {					reg = fpga_read(OMAP1510_FPGA_POWER);					reg |= OMAP1510_FPGA_PCR_COM2_EN;					fpga_write(reg, OMAP1510_FPGA_POWER);					udelay(10);				}			}			break;		case 2:			if (cpu_is_omap1510()) {				omap_cfg_reg(UART3_TX);				omap_cfg_reg(UART3_RX);			}			break;		}		omap_serial_reset(&serial_platform_data[i]);	}}static int __init omap_init(void){	return platform_device_register(&serial_device);}arch_initcall(omap_init);#define NO_LENGTH_CHECK 0xffffffffextern int omap_bootloader_tag_len;extern u8 omap_bootloader_tag[];struct omap_board_config_kernel *omap_board_config;int omap_board_config_size = 0;static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out){	struct omap_board_config_kernel *kinfo = NULL;	int i;#ifdef CONFIG_OMAP_BOOT_TAG	struct omap_board_config_entry *info = NULL;	if (omap_bootloader_tag_len > 4)		info = (struct omap_board_config_entry *) omap_bootloader_tag;	while (info != NULL) {		u8 *next;		if (info->tag == tag) {			if (skip == 0)				break;			skip--;		}		next = (u8 *) info + sizeof(*info) + info->len;		if (next >= omap_bootloader_tag + omap_bootloader_tag_len)			info = NULL;		else			info = (struct omap_board_config_entry *) next;	}	if (info != NULL) {		/* Check the length as a lame attempt to check for		 * binary inconsistancy. */		if (len != NO_LENGTH_CHECK && info->len != len) {			printk(KERN_ERR "OMAP peripheral config: Length mismatch with tag %x (want %d, got %d)\n",			       tag, len, info->len);			return NULL;		}		if (len_out != NULL)			*len_out = info->len;		return info->data;	}#endif	/* Try to find the config from the board-specific structures	 * in the kernel. */	for (i = 0; i < omap_board_config_size; i++) {		if (omap_board_config[i].tag == tag) {			kinfo = &omap_board_config[i];			break;		}	}	if (kinfo == NULL)		return NULL;	return kinfo->data;}const void *__omap_get_config(u16 tag, size_t len, int nr){        return get_config(tag, len, nr, NULL);}EXPORT_SYMBOL(__omap_get_config);const void *omap_get_var_config(u16 tag, size_t *len){        return get_config(tag, NO_LENGTH_CHECK, 0, len);}EXPORT_SYMBOL(omap_get_var_config);static int __init omap_add_serial_console(void){	const struct omap_uart_config *info;	info = omap_get_config(OMAP_TAG_UART, struct omap_uart_config);	if (info != NULL && info->console_uart) {		static char speed[11], *opt = NULL;		if (info->console_speed) {			snprintf(speed, sizeof(speed), "%u", info->console_speed);			opt = speed;		}		return add_preferred_console("ttyS", info->console_uart - 1, opt);	}	return 0;}console_initcall(omap_add_serial_console);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -