Hello linuxppc-dev community!<br><br>First of all, I want to introduce myself and my project. I'm working at the Technical University of Madrid in a project for porting Linux to an embedded system, a router. This project is my final degree thesis. This machine has a MPC8272VRMIBA processor and a custom platform and seems to be based on MPC8272ADS. The company that subsidizes us provides us a patch for making the router compatible with Linux, but it only works for Linux-2.6.21.<br>
<br>I've achieve some aims, but for now I want to make openssl compatible with SEC1.0. I want to use the Cryptographic-API with talitos to get the advantage of using crypto-processor. I've decided to use Linux-2.6.35.7 because is the latest stable version of Linux, and adds new features to "talitos". So, for now, my aim is to port the original patch to Linux-2.6.35.7 to get CPM and serial port compatibility. After that I can do kernel debugging for making Ethernet cards compatible, and finally make some benchmark for the crypto system. The bad point is that the architecture of kernel's code changes a lot and I don't know if the changes that I'm doing are in the good way.<br>
<br>I'll try to explain my best what I'm doing.<br><br>Here is the original change:<br><br>diff -rcNP linux-2.6.21/arch/powerpc/mm/init_32.c atlas_kernel/arch/powerpc/mm/init_32.c<br>*** linux-2.6.21/arch/powerpc/mm/init_32.c 2007-04-26 05:08:32.000000000 +0200<br>
--- atlas_kernel/arch/powerpc/mm/init_32.c 2008-04-24 08:43:51.000000000 +0200<br>***************<br>*** 172,178 ****<br> #ifdef CONFIG_HIGHMEM<br> ioremap_base = PKMAP_BASE;<br> #else<br>! ioremap_base = 0xfe000000UL; /* for now, could be 0xfffff000 */<br>
#endif /* CONFIG_HIGHMEM */<br> ioremap_bot = ioremap_base;<br><br>--- 172,178 ----<br> #ifdef CONFIG_HIGHMEM<br> ioremap_base = PKMAP_BASE;<br> #else<br>! ioremap_base = 0xff000000UL; /* for now, could be 0xfffff000 */ /* gonza */<br>
#endif /* CONFIG_HIGHMEM */<br> ioremap_bot = ioremap_base;<br><br>I reproduce this change with this:<br><br>diff -rc linux-2.6.35.7/arch/powerpc/include/asm/pgtable-ppc32.h linux-agrama/arch/powerpc/include/asm/pgtable-ppc32.h<br>
*** linux-2.6.35.7/arch/powerpc/include/asm/pgtable-ppc32.h 2010-09-29 03:09:08.000000000 +0200<br>--- linux-agrama/arch/powerpc/include/asm/pgtable-ppc32.h 2010-10-26 18:47:28.000000000 +0200<br>***************pq2ads<br>
*** 63,69 ****<br> #ifdef CONFIG_HIGHMEM<br> #define KVIRT_TOP PKMAP_BASE<br> #else<br>! #define KVIRT_TOP (0xfe000000UL) /* for now, could be FIXMAP_BASE ? */<br> #endif<br><br> /*<br>--- 63,69 ----<br> #ifdef CONFIG_HIGHMEM<br>
#define KVIRT_TOP PKMAP_BASE<br> #else<br>! #define KVIRT_TOP (0xff000000UL) /* for now, could be FIXMAP_BASE ? */ /* agrama, antes KVIRT_TOP era 0xfe000000UL */<br> #endif<br><br> /*<br><br>Also, I've add the next line:<br>
<br>diff -rc linux-2.6.35.7/arch/powerpc/mm/init_32.c linux-agrama/arch/powerpc/mm/init_32.c<br>*** linux-2.6.35.7/arch/powerpc/mm/init_32.c 2010-09-29 03:09:08.000000000 +0200<br>--- linux-agrama/arch/powerpc/mm/init_32.c 2010-10-29 10:28:43.000000000 +0200<br>
***************<br>*** 178,184 ****<br><br> /* Initialize early top-down ioremap allocator */<br> ioremap_bot = IOREMAP_TOP;<br>!<br> /* Map in I/O resources */<br> if (ppc_md.progress)<br> ppc_md.progress("MMU:setio", 0x302);<br>
--- 178,184 ----<br><br> /* Initialize early top-down ioremap allocator */<br> ioremap_bot = IOREMAP_TOP;<br>! ioremap_base = ioremap_bot; /*agrama*/<br> /* Map in I/O resources */<br> if (ppc_md.progress)<br>
ppc_md.progress("MMU:setio", 0x302);<br><br>¿It's correct to add the line ioremap_base=ioremap_bot or ioremap_base it not used anymore?<br><br>The next change it's about a jam on pci's kref. This line has been deleted on 2.6.21:<br>
<br>diff -rcNP linux-2.6.21/arch/powerpc/platforms/82xx/mpc82xx_ads.c atlas_kernel/arch/powerpc/platforms/82xx/mpc82xx_ads.c<br>*** linux-2.6.21/arch/powerpc/platforms/82xx/mpc82xx_ads.c 2007-04-26 05:08:32.000000000 +0200<br>
--- atlas_kernel/arch/powerpc/platforms/82xx/mpc82xx_ads.c 2008-04-24 08:43:51.000000000 +0200<br>***************<br>*** 533,539 ****<br> return;<br> }<br> pci_clk_frq = *(uint *) ptr;<br>- of_node_put(np);<br>
bus_range = get_property(np, "bus-range", &len);<br> if (bus_range == NULL || len < 2 * sizeof(int)) {<br> printk(KERN_WARNING "Can't get bus-range for %s, assume"<br><br>I didn't find an equivalent operation on 2.6.35 because the code has been changed completly. ¿Where it's included this operation about the bus?<br>
<br>Here there's a change of the macro CPM_BASE_ADDR :<br><br>diff -rcNP linux-2.6.21/arch/powerpc/platforms/82xx/pq2ads.h atlas_kernel/arch/powerpc/platforms/82xx/pq2ads.h<br>*** linux-2.6.21/arch/powerpc/platforms/82xx/pq2ads.h 2007-04-26 05:08:32.000000000 +0200<br>
--- atlas_kernel/arch/powerpc/platforms/82xx/pq2ads.h 2008-04-24 08:43:51.000000000 +0200<br>***************<br>*** 30,36 ****<br> #define CPUINFO_MACHINE "PQ2 ADS PowerPC"<br><br> /* Backword-compatibility stuff for the drivers */<br>
! #define CPM_MAP_ADDR ((uint)0xf0000000)<br> #define CPM_IRQ_OFFSET 0<br><br> /* The ADS8260 has 16, 32-bit wide control/status registers, accessed<br>--- 30,36 ----<br> #define CPUINFO_MACHINE "PQ2 ADS PowerPC"<br>
<br> /* Backword-compatibility stuff for the drivers */<br>! #define CPM_MAP_ADDR ((uint)0xff000000) /*gonza*/<br> #define CPM_IRQ_OFFSET 0<br><br>It's seems that it has to be 0xff000000, but in 2.6.35 this symbol it's not used anymore. ¿Where it's defined right now, or how I can handle this address? I need it for the next part, that it's the hardest one to modify.<br>
<br>Here comes the hardest part at the file arch/powerpc/platforms/82xx/mpc82xx_ads.c:<br>***************<br>*** 632,637 ****<br>--- 632,643 ----<br> while (1) ;<br> }<br><br>+ static void __init m82xx_map_io(void) /* gonza */<br>
+ {<br>+ io_block_mapping(CPM_MAP_ADDR, CPM_MAP_ADDR, ((uint)(4 * 64 * 1024)), _PAGE_IO);<br>+ }<br>+<br>+<br> define_machine(mpc82xx_ads)<br> {<br> .name = "MPC82xx ADS",<br>***************<br>*** 642,645 ****<br>
--- 648,652 ----<br> .get_irq = cpm2_get_irq,<br> .calibrate_decr = m82xx_calibrate_decr,<br> .restart = m82xx_restart,.halt = m82xx_halt,<br>+ .setup_io_mappings = m82xx_map_io, /* gonza */<br> };<br>
<br>Here it's a modification that sets the base address for CPM with io_block_mapping. I've seen in another discussion that io_block_mapping it's became deprecated and it's out or kernel code. Does ioremap() function became smarter and you can use it instead of io_block_mapping? I've found some part of the code that I think do the same stuff, but it's not seems working. Also, I've tried with setbat() changing the addresses for 0xff000000, but it doesn't work. Also, I've removed the original setbat line and let only mine. So it doesn't work with the both lines or letting only mine (being ioremap() or setbat()).<br>
*** linux-2.6.35.7/arch/powerpc/sysdev/cpm_common.c 2010-09-29 03:09:08.000000000 +0200<br>--- linux-agrama/arch/powerpc/sysdev/cpm_common.c 2010-10-29 13:20:35.000000000 +0200<br>***************<br>*** 58,63 ****<br>
--- 58,64 ----<br> if (cpm_udbg_txdesc) {<br> #ifdef CONFIG_CPM2<br> setbat(1, 0xf0000000, 0xf0000000, 1024*1024, PAGE_KERNEL_NCG);<br>+ ioremap(((uint)0xff000000UL),(uint)1024*64*4);<br> #endif<br>
udbg_putc = udbg_putc_cpm;<br> }<br><br>I've seen that .setup_io_mappings was removed from kernel code. It has beed called in version 2.6.21.7 from arch/powerpc/mm/init_32.c. It's has the same effect make this operation at arch/powerpc/sysdev/cpm_common.c ? Which operation should I do, ioremap(),setbat() or another one?<br>
<br>The last part of the modification it's about the serial port. At the version 2.6.21.7 you can choose where it's connected the serial port (SCC1,SCC2,SCC3,SCC4,SMC1 or SMC2). Our serial port it's connected over SMC1. We define it with the var SERIAL_CPM_SMC1 at menuconfig. At the 2.6.35.7 there's no option for do that. How should i do to force the serial on SMC1? Also, there's a change when you init the serial port:<br>
diff -rcNP linux-2.6.21/drivers/serial/cpm_uart/cpm_uart_cpm2.c atlas_kernel/drivers/serial/cpm_uart/cpm_uart_cpm2.c<br>*** linux-2.6.21/drivers/serial/cpm_uart/cpm_uart_cpm2.c 2007-04-26 05:08:32.000000000 +0200<br>--- atlas_kernel/drivers/serial/cpm_uart/cpm_uart_cpm2.c 2008-04-24 08:43:52.000000000 +0200<br>
***************<br>*** 95,105 ****<br> volatile iop_cpm2_t *io = cpm2_map(im_ioport);<br> volatile cpmux_t *cpmux = cpm2_map(im_cpmux);<br><br>! /* SMC1 is only on port D */<br>! io->iop_ppard |= 0x00c00000;<br>
! io->iop_pdird |= 0x00400000;<br>! io->iop_pdird &= ~0x00800000;<br>! io->iop_psord &= ~0x00c00000;<br><br> /* Wire BRG1 to SMC1 */<br> cpmux->cmx_smr &= 0x0f;<br>--- 95,105 ----<br> volatile iop_cpm2_t *io = cpm2_map(im_ioport);<br>
volatile cpmux_t *cpmux = cpm2_map(im_cpmux);<br><br>! /* gonza, se cambia ppard por pparc*/<br>! io->iop_pparc |= 0x0c000000;<br>! io->iop_pdirc |= 0x04000000;<br>! io->iop_pdirc &= ~0x08000000;<br>
! io->iop_psorc &= ~0x0c000000;<br><br> /* Wire BRG1 to SMC1 */<br> cpmux->cmx_smr &= 0x0f;<br><br>The change consists on use port c instead of port d. Also, the values that are written are multiplied of 0x10. In version 2.6.35.7 I've made the next change that I believe that makes the same stuff:<br>
diff -rc linux-2.6.35.7/arch/powerpc/platforms/82xx/mpc8272_ads.c linux-agrama/arch/powerpc/platforms/82xx/mpc8272_ads.c<br>*** linux-2.6.35.7/arch/powerpc/platforms/82xx/mpc8272_ads.c 2010-09-29 03:09:08.000000000 +0200<br>
--- linux-agrama/arch/powerpc/platforms/82xx/mpc8272_ads.c 2010-10-28 15:05:49.000000000 +0200<br>***************<br>*** 108,113 ****<br>--- 108,127 ----<br> {3, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},<br> {3, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},<br>
{3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY},<br>+<br>+ #if 0 /* agrama */<br>+ /* En linux-2.6.21.7 (atlas):*/<br>+ /* gonza, se cambia ppard por pparc*/<br>+ io->iop_pparc |= 0x0c 00 00 00;<br>+ 1100<br>+ io->iop_pdirc |= 0x04000000;<br>
+ io->iop_pdirc &= ~0x08000000;<br>+ io->iop_psorc &= ~0x0c000000;<br>+ #endif<br>+<br>+ /* SMC1 */ /* agrama */<br>+ {2, 26, (0*CPM_PIN_GPIO) | CPM_PIN_OUTPUT | CPM_PIN_SECONDARY}, /* agrama */<br>
+ {2, 27, (0*CPM_PIN_GPIO) | CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* agrama */<br> };<br><br>There's another modification in version 2.6.21.7 about Ethernet, but I believe that doesn't affect to serial port.<br>
<br>diff -rcNP linux-2.6.21/arch/powerpc/sysdev/fsl_soc.c atlas_kernel/arch/powerpc/sysdev/fsl_soc.c<br>*** linux-2.6.21/arch/powerpc/sysdev/fsl_soc.c 2007-04-26 05:08:32.000000000 +0200<br>--- atlas_kernel/arch/powerpc/sysdev/fsl_soc.c 2008-04-24 08:43:51.000000000 +0200<br>
***************<br>*** 679,685 ****<br> fs_enet_data.rx_ring = 32;<br> fs_enet_data.tx_ring = 32;<br> fs_enet_data.rx_copybreak = 240;<br>! fs_enet_data.use_napi = 0;<br> fs_enet_data.napi_weight = 17;<br>
fs_enet_data.mem_offset = FCC_MEM_OFFSET(fcc_index);<br> fs_enet_data.cp_page = CPM_CR_FCC_PAGE(fcc_index);<br>--- 680,686 ----<br> fs_enet_data.rx_ring = 32;<br> fs_enet_data.tx_ring = 32;<br>
fs_enet_data.rx_copybreak = 240;<br>! fs_enet_data.use_napi = 1;<br> fs_enet_data.napi_weight = 17;<br> fs_enet_data.mem_offset = FCC_MEM_OFFSET(fcc_index);<br> fs_enet_data.cp_page = CPM_CR_FCC_PAGE(fcc_index);<br>
***************<br>*** 713,731 ****<br> fs_enet_mdio_bb_data.delay =<br> mdio_bb_prop[5];<br><br> fs_enet_mdio_bb_data.irq[0] = phy_irq[0];<br> fs_enet_mdio_bb_data.irq[1] = -1;<br>
fs_enet_mdio_bb_data.irq[2] = -1;<br> fs_enet_mdio_bb_data.irq[3] = phy_irq[0];<br> fs_enet_mdio_bb_data.irq[31] = -1;<br><br> fs_enet_mdio_bb_data.mdio_dat.offset =<br>
(u32)&cpm2_immr->im_ioport.iop_pdatc;<br> fs_enet_mdio_bb_data.mdio_dir.offset =<br> (u32)&cpm2_immr->im_ioport.iop_pdirc;<br> fs_enet_mdio_bb_data.mdc_dat.offset =<br>
(u32)&cpm2_immr->im_ioport.iop_pdatc;<br>!<br> ret = platform_device_add_data(<br> fs_enet_mdio_bb_dev,<br> &fs_enet_mdio_bb_data,<br>
--- 714,747 ----<br> fs_enet_mdio_bb_data.delay =<br> mdio_bb_prop[5];<br>+ /*gonza: Creo que aqui se esta suponiendo que hay phy con direccion 0 y 3*/<br>+ /*igual que en mii-bitbang.c*/<br>
fs_enet_mdio_bb_data.irq[0] = phy_irq[0];<br> fs_enet_mdio_bb_data.irq[1] = -1;<br> fs_enet_mdio_bb_data.irq[2] = -1;<br> fs_enet_mdio_bb_data.irq[3] = phy_irq[0];<br>
fs_enet_mdio_bb_data.irq[31] = -1;<br><br>+ /*gonza: uso los campos mdio_port y mdc_port que son 0=PORTA..3=PORTD*/<br>+ offset_port_port = (u32)&cpm2_immr->im_ioport.iop_pdirb - (u32)&cpm2_immr->im_ioport.iop_pdira;<br>
+<br>+ fs_enet_mdio_bb_data.mdio_dat.offset =<br>+ (u32)&cpm2_immr->im_ioport.iop_pdata +<br>+ (offset_port_port * fs_enet_mdio_bb_data.mdio_port);<br>+ fs_enet_mdio_bb_data.mdio_dir.offset =<br>
+ (u32)&cpm2_immr->im_ioport.iop_pdira +<br>+ (offset_port_port * fs_enet_mdio_bb_data.mdio_port);<br>+ fs_enet_mdio_bb_data.mdc_dat.offset =<br>+ (u32)&cpm2_immr->im_ioport.iop_pdata +<br>
+ (offset_port_port * fs_enet_mdio_bb_data.mdc_port);<br>+ #if 0<br> fs_enet_mdio_bb_data.mdio_dat.offset =<br> (u32)&cpm2_immr->im_ioport.iop_pdatc;<br> fs_enet_mdio_bb_data.mdio_dir.offset =<br>
(u32)&cpm2_immr->im_ioport.iop_pdirc;<br> fs_enet_mdio_bb_data.mdc_dat.offset =<br> (u32)&cpm2_immr->im_ioport.iop_pdatc;<br>! #endif<br> ret = platform_device_add_data(<br>
fs_enet_mdio_bb_dev,<br> &fs_enet_mdio_bb_data,<br>***************<br>*** 733,739 ****<br> if (ret)<br> goto unreg;<br> }<br>
!<br> of_node_put(phy);<br> of_node_put(mdio);<br><br>--- 749,755 ----<br> if (ret)<br> goto unreg;<br> }<br>! <br> of_node_put(phy);<br>
of_node_put(mdio);<br><br>***************<br>*** 754,759 ****<br>--- 770,777 ----<br><br> arch_initcall(fs_enet_of_init);<br><br>+ #if 0 /* gonza */<br>+<br> static const char scc_regs[] = "regs";<br>
static const char scc_pram[] = "pram";<br><br>***************<br>*** 828,833 ****<br>--- 846,853 ----<br> }<br><br> arch_initcall(cpm_uart_of_init);<br>+ #endif<br>+<br> #endif /* CONFIG_CPM2 */<br><br> #ifdef CONFIG_8xx<br>
***************<br>*** 1022,1027 ****<br>--- 1042,1050 ----<br><br> arch_initcall(fs_enet_of_init);<br><br>+ #endif /* CONFIG_8xx */<br>+<br>+ #if defined(CONFIG_CPM2) || defined(CONFIG_8xx)<br><br> static const char *smc_regs = "regs";<br>
static const char *smc_pram = "pram";<br>***************<br>*** 1096,1099 ****<br><br> arch_initcall(cpm_smc_uart_of_init);<br><br>! #endif /* CONFIG_8xx */<br>--- 1119,1122 ----<br><br> arch_initcall(cpm_smc_uart_of_init);<br>
<br>! #endif /* CONFIG_CPM2 || CONFIG_8xx */<br><br>So, the questions are the next:<br>- linux-2.6.21/arch/powerpc/mm/init_32.c linux-2.6.35.7/arch/powerpc/mm/pgtable_32.h<br> - It's ok what I'm doing changing here KVIRT_TOP?<br>
- ioremap_base = ioremap_bot at linux-2.6.35.7/arch/powerpc/mm/init_32.c?<br>- linux-2.6.21/arch/powerpc/platforms/82xx/pq2ads.h<br> - Where and how can I define CMP_MAP_ADDR, that all the controllers can use it?<br>
- Changing the CMP_MAP_ADDR in 2.6.21.7 involves that I should use a configuration for 2.6.35 based on PQ2ADS?<br>-linux-2.6.35.7/arch/powerpc/platforms/82xx/mpc8272_ads.c<br> - How shall I the same stuff asociated to the operation .setup_io_mappings, that uses block_io_mapping?<br>
-linux-2.6.35.7/drivers/serial/cpm_uart/cpm_uart_cpm2.c<br> - How shall I force the uart driver to work on SMC1?<br> - What shall I change to make the same operation at recognizing the uart, (I mean, asingn control sequences to iop_pparc,iop_pdirc and iop_psorc), in the new "style" of kernel architecture?<br>
-linux-2.6.21/arch/powerpc/sysdev/fsl_soc.c<br> -This code it's necesary for making the UART works properly?<br><br>I really appreciate the work that you're doing adding features to the new kernel, but it's very obscure for me to make the changes that I need, so I'll apreciate very much your help with my issue. Also I think that it's a very good way to show to the begginers (as me) how to make the proper changes with the new style of the code.<br>
<br>King regards,<br>Alexandru<br>