Date: Wed, 20 Apr 2005 11:11:23 -0400 Signed-Off-By: Jason McMullan Description: MPC8xx platformization Index of changes: arch/ppc/Makefile | 2 arch/ppc/syslib/Makefile | 3 arch/ppc/syslib/m8xx_setup.c | 3 include/asm-ppc/mpc8xx.h | 31 ++ include/asm-ppc/ppc_sys.h | 2 linux/arch/ppc/platforms/8xx/mpc8xx_ads.c | 22 ++ linux/arch/ppc/platforms/8xx/mpc8xx_devices.c | 282 ++++++++++++++++++++++++++ linux/arch/ppc/platforms/8xx/mpc8xx_sys.c | 39 +++ 8 files changed, 383 insertions(+), 1 deletion(-) --- linux-orig/arch/ppc/Makefile +++ linux/arch/ppc/Makefile @@ -38,6 +38,7 @@ cpu-as-$(CONFIG_6xx) += -Wa,-maltivec cpu-as-$(CONFIG_POWER4) += -Wa,-maltivec cpu-as-$(CONFIG_E500) += -Wa,-me500 +cpu-as-$(CONFIG_8xx) += -mcpu=860 AFLAGS += $(cpu-as-y) CFLAGS += $(cpu-as-y) @@ -57,6 +58,7 @@ core-y += arch/ppc/kernel/ arch/ppc/platforms/ \ arch/ppc/mm/ arch/ppc/lib/ arch/ppc/syslib/ core-$(CONFIG_4xx) += arch/ppc/platforms/4xx/ +core-$(CONFIG_8xx) += arch/ppc/platforms/8xx/ core-$(CONFIG_85xx) += arch/ppc/platforms/85xx/ core-$(CONFIG_MATH_EMULATION) += arch/ppc/math-emu/ core-$(CONFIG_XMON) += arch/ppc/xmon/ --- /dev/null +++ linux/arch/ppc/platforms/8xx/mpc8xx_ads.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include + +extern unsigned char __res[]; + +void board_init(void) +{ + struct fec_platform_info *fec; + bd_t *bi = (void *)&__res[0]; + + /* Set up the MAC addresses for the FECs + */ + fec = ppc_sys_platform_devices[MPC8xx_CPM_FEC1].dev.platform_data; + memcpy(fec->macaddr,bi->bi_enetaddr,6); + + fec = ppc_sys_platform_devices[MPC8xx_CPM_FEC2].dev.platform_data; + memcpy(fec->macaddr,bi->bi_enetaddr,6); + fec->macaddr[5] ^= 1; +} --- /dev/null +++ linux/arch/ppc/platforms/8xx/mpc8xx_devices.c @@ -0,0 +1,282 @@ +/* + * arch/ppc/platforms/8xx/mpc8xx_devices.c + * + * MPC8xx Device descriptions + * + * Maintainer: Kumar Gala + * + * Copyright 2005 Freescale Semiconductor Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* We use offsets for IORESOURCE_MEM since we do not know at compile time + * what CCSRBAR is, will get fixed up by mach_mpc8xx_fixup + */ + +static struct fsl_i2c_platform_data mpc8xx_fsl_i2c_pdata = { + .device_flags = FSL_I2C_DEV_SEPARATE_DFSRR, +}; + +static struct fec_mii_bus_info mii_bus_info = { + .method = fecmii_fec, + .id = 0, +}; + +static struct fec_platform_info mpc8xx_fec_pdata[] = { + { + .rx_ring = 128, + .tx_ring = 16, + .rx_copybreak = 240, + + .use_napi = 1, + .napi_weight = 17, + + .bus_info = &mii_bus_info, + },{ + .rx_ring = 128, + .tx_ring = 16, + .rx_copybreak = 240, + + .use_napi = 1, + .napi_weight = 17, + + .bus_info = &mii_bus_info, + } +}; + +#define IMMAP_STRUCT(x) ((((immap_t *)0)->x)) +#define IMMAP_OFFSET(x) ((unsigned long)&IMMAP_STRUCT(x)) +#define IMMAP_END(x) (IMMAP_OFFSET(x) + sizeof(IMMAP_STRUCT(x)) - 1) + +#define CPM_OFFSET(x) IMMAP_OFFSET(im_cpm.x) +#define CPM_END(x) IMMAP_END(im_cpm.x) + +struct platform_device ppc_sys_platform_devices[] = { +#if 0 + [MPC8xx_I2C] = { + .name = "fsl-i2c", + .id = 1, + .dev.platform_data = &mpc8xx_fsl_i2c_pdata, + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = IMMAP_OFFSET(im_i2c), + .end = IMMAP_END(im_i2c), + .flags = IORESOURCE_MEM, + }, + { + .start = MPC8xx_IRQ_I2C, + .end = MPC8xx_IRQ_I2C, + .flags = IORESOURCE_IRQ, + }, + }, + }, +#endif + [MPC8xx_CPM_FEC1] = { + .name = "fsl-fec", + .id = 0, + .dev.platform_data = &mpc8xx_fec_pdata[0], + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = CPM_OFFSET(cp_fec1), + .end = CPM_END(cp_fec1), + .flags = IORESOURCE_MEM, + + }, + { + .start = MPC8xx_INT_FEC1, + .end = MPC8xx_INT_FEC1, + .flags = IORESOURCE_IRQ, + }, + }, + }, + [MPC8xx_CPM_FEC2] = { + .name = "fsl-fec", + .id = 1, + .dev.platform_data = &mpc8xx_fec_pdata[1], + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = CPM_OFFSET(cp_fec2), + .end = CPM_END(cp_fec2), + .flags = IORESOURCE_MEM, + + }, + { + .start = MPC8xx_INT_FEC2, + .end = MPC8xx_INT_FEC2, + .flags = IORESOURCE_IRQ, + }, + }, + }, + [MPC8xx_CPM_SCC1] = { + .name = "fsl-cpm-scc", + .id = 1, + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = CPM_OFFSET(cp_scc[0]), + .end = CPM_END(cp_scc[0]), + .flags = IORESOURCE_MEM, + }, + { + .start = MPC8xx_INT_SCC1, + .end = MPC8xx_INT_SCC1, + .flags = IORESOURCE_IRQ, + }, + }, + }, + [MPC8xx_CPM_SCC2] = { + .name = "fsl-cpm-scc", + .id = 2, + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = CPM_OFFSET(cp_scc[1]), + .end = CPM_END(cp_scc[1]), + .flags = IORESOURCE_MEM, + }, + { + .start = MPC8xx_INT_SCC2, + .end = MPC8xx_INT_SCC2, + .flags = IORESOURCE_IRQ, + }, + }, + }, + [MPC8xx_CPM_SCC3] = { + .name = "fsl-cpm-scc", + .id = 3, + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = CPM_OFFSET(cp_scc[2]), + .end = CPM_END(cp_scc[2]), + .flags = IORESOURCE_MEM, + }, + { + .start = MPC8xx_INT_SCC3, + .end = MPC8xx_INT_SCC3, + .flags = IORESOURCE_IRQ, + }, + }, + }, + [MPC8xx_CPM_SCC4] = { + .name = "fsl-cpm-scc", + .id = 4, + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = CPM_OFFSET(cp_scc[3]), + .end = CPM_END(cp_scc[3]), + .flags = IORESOURCE_MEM, + }, + { + .start = MPC8xx_INT_SCC4, + .end = MPC8xx_INT_SCC4, + .flags = IORESOURCE_IRQ, + }, + }, + }, +#if 0 + [MPC8xx_CPM_SPI] = { + .name = "fsl-cpm-spi", + .id = 1, + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = CPM_OFFSET(cp_spmode), + .end = CPM_END(cp_spcom), + .flags = IORESOURCE_MEM, + }, + { + .start = MPC8xx_INT_SPI, + .end = MPC8xx_INT_SPI, + .flags = IORESOURCE_IRQ, + }, + }, + }, +#endif + [MPC8xx_CPM_SMC1] = { + .name = "fsl-cpm-smc", + .id = 1, + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = CPM_OFFSET(cp_smc[0]), + .end = CPM_END(cp_smc[0]), + .flags = IORESOURCE_MEM, + }, + { + .start = MPC8xx_INT_SMC1, + .end = MPC8xx_INT_SMC1, + .flags = IORESOURCE_IRQ, + }, + }, + }, + [MPC8xx_CPM_SMC2] = { + .name = "fsl-cpm-smc", + .id = 2, + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = CPM_OFFSET(cp_smc[1]), + .end = CPM_END(cp_smc[1]), + .flags = IORESOURCE_MEM, + }, + { + .start = MPC8xx_INT_SMC2, + .end = MPC8xx_INT_SMC2, + .flags = IORESOURCE_IRQ, + }, + }, + }, +#if 0 + [MPC8xx_CPM_USB] = { + .name = "fsl-cpm-usb", + .id = 0, + .num_resources = 2, + .resource = (struct resource[]) { + { + .start = CPM_OFFSET(cp_scc[0]), + .end = CPM_END(cp_scc[0]), + .flags = IORESOURCE_MEM, + }, + { + .start = MPC8xx_INT_USB, + .end = MPC8xx_INT_USB, + .flags = IORESOURCE_IRQ, + }, + }, + }, +#endif +}; + +static int __init mach_mpc8xx_fixup(struct platform_device *pdev) +{ + ppc_sys_fixup_mem_resource(pdev, IMAP_ADDR); + return 0; +} + +static int __init mach_mpc8xx_init(void) +{ + ppc_sys_device_fixup = mach_mpc8xx_fixup; + return 0; +} + +postcore_initcall(mach_mpc8xx_init); --- /dev/null +++ linux/arch/ppc/platforms/8xx/mpc8xx_sys.c @@ -0,0 +1,39 @@ +/* + * arch/ppc/platforms/8xx/mpc8xx_sys.c + * + * MPC8xx System descriptions + * + * Maintainer: Kumar Gala + * + * Copyright 2005 Freescale Semiconductor Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include + +struct ppc_sys_spec *cur_ppc_sys_spec; +struct ppc_sys_spec ppc_sys_specs[] = { + { + .ppc_sys_name = "MPC885", + .mask = 0xFFFF0000, + .value = 0x00500000, + .num_devices = 2, + .device_list = (enum ppc_sys_devices[]) + { + MPC8xx_CPM_FEC1, + MPC8xx_CPM_SCC1, + }, + }, + { /* default match */ + .ppc_sys_name = "", + .mask = 0x00000000, + .value = 0x00000000, + }, +}; --- linux-orig/arch/ppc/syslib/Makefile +++ linux/arch/ppc/syslib/Makefile @@ -33,7 +33,8 @@ obj-$(CONFIG_PCI) += indirect_pci.o pci_auto.o ppc405_pci.o endif endif -obj-$(CONFIG_8xx) += m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y) +obj-$(CONFIG_8xx) += m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y) \ + ppc_sys.o ifeq ($(CONFIG_8xx),y) obj-$(CONFIG_PCI) += qspan_pci.o i8259.o endif --- linux-orig/arch/ppc/syslib/m8xx_setup.c +++ linux/arch/ppc/syslib/m8xx_setup.c @@ -45,6 +45,7 @@ #include #include #include +#include #include "ppc8xx_pic.h" @@ -408,6 +409,8 @@ strcpy(cmd_line, (char *)(r6+KERNELBASE)); } + identify_ppc_sys_by_id(mfspr(PVR)); + ppc_md.setup_arch = m8xx_setup_arch; ppc_md.show_percpuinfo = m8xx_show_percpuinfo; ppc_md.irq_canonicalize = NULL; --- linux-orig/include/asm-ppc/mpc8xx.h +++ linux/include/asm-ppc/mpc8xx.h @@ -90,6 +90,10 @@ #endif #ifndef __ASSEMBLY__ +#include +#include +#include + /* The "residual" data board information structure the boot loader * hands to us. */ @@ -97,7 +101,34 @@ struct pt_regs; +/* Let modules/drivers get at CCSRBAR */ +extern phys_addr_t get_ccsrbar(void); + +#define MPC8xx_INT_FEC1 SIU_LEVEL1 +#define MPC8xx_INT_FEC2 SIU_LEVEL3 +#define MPC8xx_INT_SCC1 (CPM_IRQ_OFFSET + CPMVEC_SCC1) +#define MPC8xx_INT_SCC2 (CPM_IRQ_OFFSET + CPMVEC_SCC2) +#define MPC8xx_INT_SCC3 (CPM_IRQ_OFFSET + CPMVEC_SCC3) +#define MPC8xx_INT_SCC4 (CPM_IRQ_OFFSET + CPMVEC_SCC4) +#define MPC8xx_INT_SMC1 (CPM_IRQ_OFFSET + CPMVEC_SMC1) +#define MPC8xx_INT_SMC2 (CPM_IRQ_OFFSET + CPMVEC_SMC2) + +enum ppc_sys_devices { + MPC8xx_I2C, + MPC8xx_CPM_FEC1, + MPC8xx_CPM_FEC2, + MPC8xx_CPM_SPI, + MPC8xx_CPM_USB, + MPC8xx_CPM_SCC1, + MPC8xx_CPM_SCC2, + MPC8xx_CPM_SCC3, + MPC8xx_CPM_SCC4, + MPC8xx_CPM_SMC1, + MPC8xx_CPM_SMC2, +}; #endif /* !__ASSEMBLY__ */ + + #endif /* CONFIG_8xx */ #endif /* __CONFIG_8xx_DEFS */ #endif /* __KERNEL__ */ --- linux-orig/include/asm-ppc/ppc_sys.h +++ linux/include/asm-ppc/ppc_sys.h @@ -23,6 +23,8 @@ #if defined(CONFIG_85xx) #include +#elif defined(CONFIG_8xx) +#include #else #error "need definition of ppc_sys_devices" #endif