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

📄 fsl_soc.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
		id = of_get_property(np, "device-id", NULL);		cpm_uart_data.fs_no = *id;		model = of_get_property(np, "model", NULL);		strcpy(cpm_uart_data.fs_type, model);		cpm_uart_data.uart_clk = ppc_proc_freq;		cpm_uart_data.tx_num_fifo = 4;		cpm_uart_data.tx_buf_size = 32;		cpm_uart_data.rx_num_fifo = 4;		cpm_uart_data.rx_buf_size = 32;		cpm_uart_data.clk_rx = *((u32 *)of_get_property(np,						"rx-clock", NULL));		cpm_uart_data.clk_tx = *((u32 *)of_get_property(np,						"tx-clock", NULL));		ret =		    platform_device_add_data(cpm_uart_dev, &cpm_uart_data,					     sizeof(struct						    fs_uart_platform_info));		if (ret)			goto unreg;	}	return 0;unreg:	platform_device_unregister(cpm_uart_dev);err:	return ret;}arch_initcall(cpm_uart_of_init);#endif /* CONFIG_CPM2 */#ifdef CONFIG_8xxextern void init_scc_ioports(struct fs_platform_info*);extern int platform_device_skip(const char *model, int id);static int __init fs_enet_mdio_of_init(void){	struct device_node *np;	unsigned int i;	struct platform_device *mdio_dev;	struct resource res;	int ret;	for (np = NULL, i = 0;	     (np = of_find_compatible_node(np, "mdio", "fs_enet")) != NULL;	     i++) {		struct fs_mii_fec_platform_info mdio_data;		memset(&res, 0, sizeof(res));		memset(&mdio_data, 0, sizeof(mdio_data));		ret = of_address_to_resource(np, 0, &res);		if (ret)			goto err;		mdio_dev =		    platform_device_register_simple("fsl-cpm-fec-mdio",						    res.start, &res, 1);		if (IS_ERR(mdio_dev)) {			ret = PTR_ERR(mdio_dev);			goto err;		}		mdio_data.mii_speed = ((((ppc_proc_freq + 4999999) / 2500000) / 2) & 0x3F) << 1;		ret =		    platform_device_add_data(mdio_dev, &mdio_data,					     sizeof(struct fs_mii_fec_platform_info));		if (ret)			goto unreg;	}	return 0;unreg:	platform_device_unregister(mdio_dev);err:	return ret;}arch_initcall(fs_enet_mdio_of_init);static const char *enet_regs = "regs";static const char *enet_pram = "pram";static const char *enet_irq = "interrupt";static char bus_id[9][BUS_ID_SIZE];static int __init fs_enet_of_init(void){	struct device_node *np;	unsigned int i;	struct platform_device *fs_enet_dev = NULL;	struct resource res;	int ret;	for (np = NULL, i = 0;	     (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL;	     i++) {		struct resource r[4];		struct device_node *phy = NULL, *mdio = NULL;		struct fs_platform_info fs_enet_data;		const unsigned int *id;		const unsigned int *phy_addr;		const void *mac_addr;		const phandle *ph;		const char *model;		memset(r, 0, sizeof(r));		memset(&fs_enet_data, 0, sizeof(fs_enet_data));		model = of_get_property(np, "model", NULL);		if (model == NULL) {			ret = -ENODEV;			goto unreg;		}		id = of_get_property(np, "device-id", NULL);		fs_enet_data.fs_no = *id;		if (platform_device_skip(model, *id))			continue;		ret = of_address_to_resource(np, 0, &r[0]);		if (ret)			goto err;		r[0].name = enet_regs;		mac_addr = of_get_mac_address(np);		if (mac_addr)			memcpy(fs_enet_data.macaddr, mac_addr, 6);		ph = of_get_property(np, "phy-handle", NULL);		if (ph != NULL)			phy = of_find_node_by_phandle(*ph);		if (phy != NULL) {			phy_addr = of_get_property(phy, "reg", NULL);			fs_enet_data.phy_addr = *phy_addr;			fs_enet_data.has_phy = 1;			mdio = of_get_parent(phy);			ret = of_address_to_resource(mdio, 0, &res);			if (ret) {				of_node_put(phy);				of_node_put(mdio);                                goto unreg;			}		}		model = of_get_property(np, "model", NULL);		strcpy(fs_enet_data.fs_type, model);		if (strstr(model, "FEC")) {			r[1].start = r[1].end = irq_of_parse_and_map(np, 0);			r[1].flags = IORESOURCE_IRQ;			r[1].name = enet_irq;			fs_enet_dev =				    platform_device_register_simple("fsl-cpm-fec", i, &r[0], 2);			if (IS_ERR(fs_enet_dev)) {				ret = PTR_ERR(fs_enet_dev);				goto err;			}			fs_enet_data.rx_ring = 128;			fs_enet_data.tx_ring = 16;			fs_enet_data.rx_copybreak = 240;			fs_enet_data.use_napi = 1;			fs_enet_data.napi_weight = 17;			snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%x:%02x",							(u32)res.start, fs_enet_data.phy_addr);			fs_enet_data.bus_id = (char*)&bus_id[i];			fs_enet_data.init_ioports = init_fec_ioports;		}		if (strstr(model, "SCC")) {			ret = of_address_to_resource(np, 1, &r[1]);			if (ret)				goto err;			r[1].name = enet_pram;			r[2].start = r[2].end = irq_of_parse_and_map(np, 0);			r[2].flags = IORESOURCE_IRQ;			r[2].name = enet_irq;			fs_enet_dev =				    platform_device_register_simple("fsl-cpm-scc", i, &r[0], 3);			if (IS_ERR(fs_enet_dev)) {				ret = PTR_ERR(fs_enet_dev);				goto err;			}			fs_enet_data.rx_ring = 64;			fs_enet_data.tx_ring = 8;			fs_enet_data.rx_copybreak = 240;			fs_enet_data.use_napi = 1;			fs_enet_data.napi_weight = 17;			snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%s", "fixed@10:1");                        fs_enet_data.bus_id = (char*)&bus_id[i];			fs_enet_data.init_ioports = init_scc_ioports;		}		of_node_put(phy);		of_node_put(mdio);		ret = platform_device_add_data(fs_enet_dev, &fs_enet_data,					     sizeof(struct						    fs_platform_info));		if (ret)			goto unreg;	}	return 0;unreg:	platform_device_unregister(fs_enet_dev);err:	return ret;}arch_initcall(fs_enet_of_init);static int __init fsl_pcmcia_of_init(void){	struct device_node *np = NULL;	/*	 * Register all the devices which type is "pcmcia"	 */	while ((np = of_find_compatible_node(np,			"pcmcia", "fsl,pq-pcmcia")) != NULL)			    of_platform_device_create(np, "m8xx-pcmcia", NULL);	return 0;}arch_initcall(fsl_pcmcia_of_init);static const char *smc_regs = "regs";static const char *smc_pram = "pram";static int __init cpm_smc_uart_of_init(void){	struct device_node *np;	unsigned int i;	struct platform_device *cpm_uart_dev;	int ret;	for (np = NULL, i = 0;	     (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL;	     i++) {		struct resource r[3];		struct fs_uart_platform_info cpm_uart_data;		const int *id;		const char *model;		memset(r, 0, sizeof(r));		memset(&cpm_uart_data, 0, sizeof(cpm_uart_data));		ret = of_address_to_resource(np, 0, &r[0]);		if (ret)			goto err;		r[0].name = smc_regs;		ret = of_address_to_resource(np, 1, &r[1]);		if (ret)			goto err;		r[1].name = smc_pram;		r[2].start = r[2].end = irq_of_parse_and_map(np, 0);		r[2].flags = IORESOURCE_IRQ;		cpm_uart_dev =		    platform_device_register_simple("fsl-cpm-smc:uart", i, &r[0], 3);		if (IS_ERR(cpm_uart_dev)) {			ret = PTR_ERR(cpm_uart_dev);			goto err;		}		model = of_get_property(np, "model", NULL);		strcpy(cpm_uart_data.fs_type, model);		id = of_get_property(np, "device-id", NULL);		cpm_uart_data.fs_no = *id;		cpm_uart_data.uart_clk = ppc_proc_freq;		cpm_uart_data.tx_num_fifo = 4;		cpm_uart_data.tx_buf_size = 32;		cpm_uart_data.rx_num_fifo = 4;		cpm_uart_data.rx_buf_size = 32;		ret =		    platform_device_add_data(cpm_uart_dev, &cpm_uart_data,					     sizeof(struct						    fs_uart_platform_info));		if (ret)			goto unreg;	}	return 0;unreg:	platform_device_unregister(cpm_uart_dev);err:	return ret;}arch_initcall(cpm_smc_uart_of_init);#endif /* CONFIG_8xx */#endif /* CONFIG_PPC_CPM_NEW_BINDING */int __init fsl_spi_init(struct spi_board_info *board_infos,			unsigned int num_board_infos,			void (*activate_cs)(u8 cs, u8 polarity),			void (*deactivate_cs)(u8 cs, u8 polarity)){	struct device_node *np;	unsigned int i;	const u32 *sysclk;	/* SPI controller is either clocked from QE or SoC clock */	np = of_find_node_by_type(NULL, "qe");	if (!np)		np = of_find_node_by_type(NULL, "soc");	if (!np)		return -ENODEV;	sysclk = of_get_property(np, "bus-frequency", NULL);	if (!sysclk)		return -ENODEV;	for (np = NULL, i = 1;	     (np = of_find_compatible_node(np, "spi", "fsl_spi")) != NULL;	     i++) {		int ret = 0;		unsigned int j;		const void *prop;		struct resource res[2];		struct platform_device *pdev;		struct fsl_spi_platform_data pdata = {			.activate_cs = activate_cs,			.deactivate_cs = deactivate_cs,		};		memset(res, 0, sizeof(res));		pdata.sysclk = *sysclk;		prop = of_get_property(np, "reg", NULL);		if (!prop)			goto err;		pdata.bus_num = *(u32 *)prop;		prop = of_get_property(np, "mode", NULL);		if (prop && !strcmp(prop, "cpu-qe"))			pdata.qe_mode = 1;		for (j = 0; j < num_board_infos; j++) {			if (board_infos[j].bus_num == pdata.bus_num)				pdata.max_chipselect++;		}		if (!pdata.max_chipselect)			goto err;		ret = of_address_to_resource(np, 0, &res[0]);		if (ret)			goto err;		ret = of_irq_to_resource(np, 0, &res[1]);		if (ret == NO_IRQ)			goto err;		pdev = platform_device_alloc("mpc83xx_spi", i);		if (!pdev)			goto err;		ret = platform_device_add_data(pdev, &pdata, sizeof(pdata));		if (ret)			goto unreg;		ret = platform_device_add_resources(pdev, res,						    ARRAY_SIZE(res));		if (ret)			goto unreg;		ret = platform_device_register(pdev);		if (ret)			goto unreg;		continue;unreg:		platform_device_del(pdev);err:		continue;	}	return spi_register_board_info(board_infos, num_board_infos);}#if defined(CONFIG_PPC_85xx) || defined(CONFIG_PPC_86xx)static __be32 __iomem *rstcr;static int __init setup_rstcr(void){	struct device_node *np;	np = of_find_node_by_name(NULL, "global-utilities");	if ((np && of_get_property(np, "fsl,has-rstcr", NULL))) {		const u32 *prop = of_get_property(np, "reg", NULL);		if (prop) {			/* map reset control register			 * 0xE00B0 is offset of reset control register			 */			rstcr = ioremap(get_immrbase() + *prop + 0xB0, 0xff);			if (!rstcr)				printk (KERN_EMERG "Error: reset control "						"register not mapped!\n");		}	} else		printk (KERN_INFO "rstcr compatible register does not exist!\n");	if (np)		of_node_put(np);	return 0;}arch_initcall(setup_rstcr);void fsl_rstcr_restart(char *cmd){	local_irq_disable();	if (rstcr)		/* set reset control register */		out_be32(rstcr, 0x2);	/* HRESET_REQ */	while (1) ;}#endif

⌨️ 快捷键说明

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