From: Matt Porter <mporter@KERNEL.CRASHING.ORG> Date: 2004-06-03 20:48:04
On Thu, Jun 03, 2004 at 10:19:07PM +0200, Sylvain Munaut wrote:
>>> See the thread starting at
>>> http://lists.linuxppc.org/linuxppc-dev/200311/msg00000.html
>>>
>>> David even posted on this list to get feedback from the
>>> community. But I haven't seen a single reply on the mailing
>>> lists.
>>
>> So? Repost. I miss stuff the first time around a lot of times
>> myself [this is not to indicate that I would necessarily comment
>> on 5200 stuff, just an example].
>
>
> And this time do it against 2.6. Even if 2.4 wasn't necessarily
> frozen at the time we first tried, it is now.
Actually I got some patch to support MPC5200 ( and only this one, no
mgt5100 stuff ) for 2.6
It only supports booting, serial console and i2c. Not much but could
that be put in official tree if I submit it ? Or does it need to
support more than that to worth inclusion.
So that at least if someone tries to implement more ( I'll resume my
work on it in a few weeks ), it has a base already in official tree.
Why not? You're the only one showing interest in supporting 5200 in
2.6. Post the patch and if it's clean it can go in. The "i2c", I
assume, is an i2c host adapter driver so that needs to be separated
so it can go to gregkh. Don't lump it in with the include/asm-ppc
and arch/ppc core support. :)
-Matt
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Why not? You're the only one showing interest in supporting 5200 in
2.6.
Well, I'm getting used to it. I'm also working on ARM IXP1200 on 2.6,
and I'm also the only one AFAIK ;)
Post the patch and if it's clean it can go in. The "i2c", I assume,
is an i2c host adapter driver so that needs to be separated so it
can go to gregkh. Don't lump it in with the include/asm-ppc and
arch/ppc core support. :)
Here it is, slightly delayed because of hardrive crash and need to
rename all 'Motorola' to 'Freescale' ;)
It's there :
http://www.246tNt.com/linux-2.5-mpc52xx-pending-20040610.diff
bk://bkbits.246tNt.com/linux-2.5-mpc52xx-pending
I haven't inlined or attached it because it's quite large ( ~80k ).
But still, here the summary of the changes, so you at least know what
you're pulling ;)
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/06/10 21:08:41+02:00 tnt@246tnt-laptop.(none)
# Added support for Freescale MPC52xx, both the processor and the
LITE5200 devboard
#
# include/asm-ppc/mpc52xx_psc.h
# 2004/06/10 21:04:05+02:00 tnt@246tnt-laptop.(none) +202 -0
#
# include/asm-ppc/mpc52xx_psc.h
# 2004/06/10 21:04:05+02:00 tnt@246tnt-laptop.(none) +0 -0
# BitKeeper file
/home/tnt/musicbox/kernel/linux-2.5-mpc52xx-pending/include/asm-ppc/mpc52xx_psc.h
#
# include/asm-ppc/mpc52xx.h
# 2004/06/10 21:04:04+02:00 tnt@246tnt-laptop.(none) +427 -0
#
# drivers/serial/mpc52xx_uart.c
# 2004/06/10 21:04:04+02:00 tnt@246tnt-laptop.(none) +872 -0
#
# include/asm-ppc/mpc52xx.h
# 2004/06/10 21:04:04+02:00 tnt@246tnt-laptop.(none) +0 -0
# BitKeeper file
/home/tnt/musicbox/kernel/linux-2.5-mpc52xx-pending/include/asm-ppc/mpc52xx.h
#
# drivers/serial/mpc52xx_uart.c
# 2004/06/10 21:04:04+02:00 tnt@246tnt-laptop.(none) +0 -0
# BitKeeper file
/home/tnt/musicbox/kernel/linux-2.5-mpc52xx-pending/drivers/serial/mpc52xx_uart.c
#
# arch/ppc/syslib/mpc52xx_setup.c
# 2004/06/10 21:04:03+02:00 tnt@246tnt-laptop.(none) +136 -0
#
# arch/ppc/syslib/mpc52xx_setup.c
# 2004/06/10 21:04:03+02:00 tnt@246tnt-laptop.(none) +0 -0
# BitKeeper file
/home/tnt/musicbox/kernel/linux-2.5-mpc52xx-pending/arch/ppc/syslib/mpc52xx_setup.c
#
# arch/ppc/syslib/mpc52xx_pic.c
# 2004/06/10 21:04:02+02:00 tnt@246tnt-laptop.(none) +259 -0
#
# arch/ppc/platforms/lite5200.h
# 2004/06/10 21:04:02+02:00 tnt@246tnt-laptop.(none) +34 -0
#
# arch/ppc/syslib/mpc52xx_pic.c
# 2004/06/10 21:04:02+02:00 tnt@246tnt-laptop.(none) +0 -0
# BitKeeper file
/home/tnt/musicbox/kernel/linux-2.5-mpc52xx-pending/arch/ppc/syslib/mpc52xx_pic.c
#
# arch/ppc/platforms/lite5200.h
# 2004/06/10 21:04:02+02:00 tnt@246tnt-laptop.(none) +0 -0
# BitKeeper file
/home/tnt/musicbox/kernel/linux-2.5-mpc52xx-pending/arch/ppc/platforms/lite5200.h
#
# arch/ppc/platforms/lite5200.c
# 2004/06/10 21:04:01+02:00 tnt@246tnt-laptop.(none) +155 -0
#
# arch/ppc/platforms/lite5200.c
# 2004/06/10 21:04:01+02:00 tnt@246tnt-laptop.(none) +0 -0
# BitKeeper file
/home/tnt/musicbox/kernel/linux-2.5-mpc52xx-pending/arch/ppc/platforms/lite5200.c
#
# arch/ppc/configs/lite5200_defconfig
# 2004/06/10 21:04:00+02:00 tnt@246tnt-laptop.(none) +477 -0
#
# arch/ppc/configs/lite5200_defconfig
# 2004/06/10 21:04:00+02:00 tnt@246tnt-laptop.(none) +0 -0
# BitKeeper file
/home/tnt/musicbox/kernel/linux-2.5-mpc52xx-pending/arch/ppc/configs/lite5200_defconfig
#
# Documentation/powerpc/mpc52xx.txt
# 2004/06/10 21:03:59+02:00 tnt@246tnt-laptop.(none) +70 -0
#
# include/linux/serial_core.h
# 2004/06/10 21:03:59+02:00 tnt@246tnt-laptop.(none) +3 -0
# Added port type for the Freescale MPC52xx PSC
#
# include/asm-ppc/ppcboot.h
# 2004/06/10 21:03:59+02:00 tnt@246tnt-laptop.(none) +7 -0
# Added specific fields for the Freescale MPC52xx
#
# drivers/serial/Makefile
# 2004/06/10 21:03:59+02:00 tnt@246tnt-laptop.(none) +1 -0
# Added options for the Freescale MPC52xx PSC
#
# drivers/serial/Kconfig
# 2004/06/10 21:03:59+02:00 tnt@246tnt-laptop.(none) +18 -0
# Added options for the Freescale MPC52xx PSC
#
# arch/ppc/syslib/Makefile
# 2004/06/10 21:03:59+02:00 tnt@246tnt-laptop.(none) +1 -0
# Added options for the Freescale MPC52xx and the standard LITE5200
devboard
#
# arch/ppc/platforms/Makefile
# 2004/06/10 21:03:59+02:00 tnt@246tnt-laptop.(none) +1 -0
# Added options for the Freescale MPC52xx and the standard LITE5200
devboard
#
# arch/ppc/kernel/cputable.c
# 2004/06/10 21:03:59+02:00 tnt@246tnt-laptop.(none) +8 -0
# Added entry for the Freescale MPC52xx
#
# arch/ppc/Kconfig
# 2004/06/10 21:03:59+02:00 tnt@246tnt-laptop.(none) +20 -8
# Added options for the Freescale MPC52xx and the standard LITE5200
devboard
#
# Documentation/powerpc/mpc52xx.txt
# 2004/06/10 21:03:59+02:00 tnt@246tnt-laptop.(none) +0 -0
# BitKeeper file
/home/tnt/musicbox/kernel/linux-2.5-mpc52xx-pending/Documentation/powerpc/mpc52xx.txt
#
Sylvain Munaut
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
FWIW, I'd like to see the above go into linux-2.5.
I found a few issues.
- need to call uart_update_timeout
- Maximum delay for console_write (printk) was too short
- one missed icecube to lite5200 name change.
This patch applies on top Sylvain's patch above.
-Dale
===== drivers/serial/mpc52xx_uart.c 1.1 vs edited =====
@@ -289,15 +289,18 @@/* Get the lock */spin_lock_irqsave(&port->lock,flags);+/* Update the per-port timeout */+uart_update_timeout(port,new->c_cflag,baud);+/* Do our best to flush TX & RX, so we don't loose anything *//* But we don't wait indefinitly ! */-j=1000;/* Maximum wait */+j=1000000;/* Maximum wait *//* FIXME Can't receive chars since set_termios might be called at early*bootfortheconsole,allstuffisnotyetreadytoreceiveatthat*timeandthatjustmakesthekerneloops*//* while (j-- && mpc52xx_uart_int_rx_chars(port)); */while(!(in_be16(&psc->mpc52xx_psc_status)&MPC52xx_PSC_SR_TXEMP)&&-j--)+--j)udelay(1);if(!j)
@@ -588,40 +591,28 @@/* Disable interrupts */out_be16(&psc->mpc52xx_psc_imr,0);++/* Wait the TX buffer to be empty */+j=1000000;/* Maximum wait */+while(!(in_be16(&psc->mpc52xx_psc_status)&MPC52xx_PSC_SR_TXEMP)&&+j--)+udelay(1);/* Write all the chars */for(i=0;i<count;i++){--/* Wait the TX buffer to be ready */-j=10000;/* Maximum wait */-while(!(in_be16(&psc->mpc52xx_psc_status)&-MPC52xx_PSC_SR_TXRDY)&&-j--)-udelay(1);-/* Send the char */out_8(&psc->mpc52xx_psc_buffer_8,*s);/* Line return handling */-if(*s++=='\n'){-/* Wait the TX buffer to be ready */-j=10000;/* Maximum wait */-while(!(in_be16(&psc->mpc52xx_psc_status)&-MPC52xx_PSC_SR_TXRDY)&&-j--)-udelay(1);--/* Send the char */+if(*s++=='\n')out_8(&psc->mpc52xx_psc_buffer_8,'\r');-}-}-/* Wait the TX buffer to be empty */-/* I'm not sure we really need to ... */-j=10000;/* Maximum wait */-while(!(in_be16(&psc->mpc52xx_psc_status)&MPC52xx_PSC_SR_TXEMP)&&-j--)-udelay(1);+/* Wait the TX buffer to be empty */+j=100000;/* Maximum wait */+while(!(in_be16(&psc->mpc52xx_psc_status)&+MPC52xx_PSC_SR_TXEMP)&&j--)+udelay(1);+}/* Restore interrupt state */out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
===== include/asm-ppc/mpc52xx.h 1.1 vs edited =====
This patch allows Sylvain's 2.6 support for the lite5200 to boot
from dBUG as well as U-Boot.
When the arch/ppc/boot/simple bootwrapper is used, it computes the
values that U-boot would have supplied and stores them in __res.
That works for all needed fields except __res.bi_baudrate, which
can't be determined from the environment. So, I added
CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD to supply the default baud rate.
The value of CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD is ignored if the
bootloader (U-boot) supplies the baudrate.
-Dale Farnsworth
===== arch/ppc/boot/common/misc-common.c 1.11 vs edited =====
@@ -113,6 +113,12 @@entrypoint-$(CONFIG_SPRUCE):=0x00800000misc-$(CONFIG_SPRUCE)+=misc-spruce.o+zimage-$(CONFIG_LITE5200):=zImage-STRIPELF+zimageinitrd-$(CONFIG_LITE5200):=zImage.initrd-STRIPELF+end-$(CONFIG_LITE5200):=lite5200+cacheflag-$(CONFIG_LITE5200):=-include$(clear_L2_L3)++# SMP images should have a '.smp' suffix.end-$(CONFIG_SMP):=$(end-y).smp
@@ -72,28 +72,34 @@platform_init(unsignedlongr3,unsignedlongr4,unsignedlongr5,unsignedlongr6,unsignedlongr7){-parse_bootinfo(find_bootinfo());/* Generic MPC52xx platform initialization *//* TODO Create one and move a max of stuff in it.Putthisinitinthesyslib*/-/* Load the bd_t board info structure */-if(r3)-memcpy((void*)&__res,(void*)(r3+KERNELBASE),sizeof(bd_t));+structbi_record*bootinfo=find_bootinfo();++if(bootinfo)+parse_bootinfo(bootinfo);+else{+/* Load the bd_t board info structure */+if(r3)+memcpy((void*)&__res,(void*)(r3+KERNELBASE),+sizeof(bd_t));#ifdef CONFIG_BLK_DEV_INITRD-/* Load the initrd */-if(r4){-initrd_start=r4+KERNELBASE;-initrd_end=r5+KERNELBASE;-}+/* Load the initrd */+if(r4){+initrd_start=r4+KERNELBASE;+initrd_end=r5+KERNELBASE;+}#endif-/* Load the command line */-if(r6){-*(char*)(r7+KERNELBASE)=0;-strcpy(cmd_line,(char*)(r6+KERNELBASE));+/* Load the command line */+if(r6){+*(char*)(r7+KERNELBASE)=0;+strcpy(cmd_line,(char*)(r6+KERNELBASE));+}}/* BAT setup */
===== arch/ppc/syslib/mpc52xx_setup.c 1.1 vs edited =====
@@ -110,8 +118,25 @@unsignedlong__initmpc52xx_find_end_of_memory(void){-/* We just read uBoot. We don't support anything else right now */-return__res.bi_memsize;+u32ramsize=__res.bi_memsize;++/*+*ifbootloaderpassedamemsize,justuseit+*elsegetsizefromsdramconfigregisters+*/+if(ramsize==0){+u32sdram_config_0=in_be32((u32*)MPC52xx_SDRAM_CONFIG_0);+u32sdram_config_1=in_be32((u32*)MPC52xx_SDRAM_CONFIG_1);++if((sdram_config_0&0x1f)>=0x13)+ramsize=1<<((sdram_config_0&0xf)+17);++if(((sdram_config_1&0x1f)>=0x13)&&+((sdram_config_1&0xfff00000)==ramsize))+ramsize+=1<<((sdram_config_1&0xf)+17);+}++returnramsize;}void__init
@@ -125,12 +150,46 @@mpc52xx_calibrate_decr(void){intfreq,divisor;-+structmpc52xx_rtc*rtc=(structmpc52xx_rtc*)MPC52xx_RTC;+structmpc52xx_cdm*cdm=(structmpc52xx_cdm*)MPC52xx_CDM;+intcurrent_time,previous_time;+inttbl_start,tbl_end;+intcpufreq,ipbfreq,pcifreq;+freq=__res.bi_busfreq;+/* if bootloader didn't pass bus frequencies, calculate them */+if(freq==0){+previous_time=in_be32(&rtc->time);+while((current_time=in_be32(&rtc->time))==previous_time);+tbl_start=get_tbl();+previous_time=current_time;+while((current_time=in_be32(&rtc->time))==previous_time);+tbl_end=get_tbl();++freq=(tbl_end-tbl_start)*4;++cpufreq=freq/10*cpu_52xx[in_be32(&cdm->rstcfg)&0x1f];+ipbfreq=(in_8(&cdm->ipb_clk_sel)&1)?+freq/2:freq;+switch(in_8(&cdm->pci_clk_sel)&3){+case0:+pcifreq=ipbfreq;+break;+case1:+pcifreq=ipbfreq/2;+break;+default:+pcifreq=ipbfreq/4;+break;+}+__res.bi_busfreq=freq;+__res.bi_intfreq=cpufreq;+__res.bi_ipbfreq=ipbfreq;+__res.bi_pcifreq=pcifreq;+}divisor=4;tb_ticks_per_jiffy=freq/HZ/divisor;tb_to_us=mulhwu_scale_factor(freq/divisor,1000000);}-
@@ -633,6 +633,15 @@helpSelectthisoptionsifyou'dliketouseoneofthePSCserialportoftheFreescaleMPC52xxfamilyasaconsole.++configSERIAL_MPC52xx_CONSOLE_BAUD+int"Freescale MPC52xx family PSC serial port baud"+depends onSERIAL_MPC52xx_CONSOLE=y+default"9600"+help+SelecttheMPC52xxconsolebaudrate.+Thisvalueisonlyusedifthebootloaderdoesn'tpassinthe+consolebaudrateendmenu
===== drivers/serial/mpc52xx_uart.c 1.1 vs edited =====
@@ -562,9 +565,11 @@out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1);mr1=in_8(&psc->mode);-/* Parse them */-*baud=__res.bi_baudrate;/* CT{U,L}R are write-only ! */+/* CT{U,L}R are write-only ! */+*baud=__res.bi_baudrate?+__res.bi_baudrate:CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD;+/* Parse them */switch(mr1&MPC52xx_PSC_MODE_BITS_MASK){caseMPC52xx_PSC_MODE_5_BITS:*bits=5;break;caseMPC52xx_PSC_MODE_6_BITS:*bits=6;break;
===== include/asm-ppc/mpc52xx.h 1.1 vs edited =====
Thanks,
I think a file ( arch/ppc/boot/simple/mpc52xx_tty.c ) is missing from
the patch.
Sylvain Munaut
Dale Farnsworth wrote:
This patch allows Sylvain's 2.6 support for the lite5200 to boot
from dBUG as well as U-Boot.
When the arch/ppc/boot/simple bootwrapper is used, it computes the
values that U-boot would have supplied and stores them in __res.
That works for all needed fields except __res.bi_baudrate, which
can't be determined from the environment. So, I added
CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD to supply the default baud rate.
The value of CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD is ignored if the
bootloader (U-boot) supplies the baudrate.
-Dale Farnsworth
FWIW, I'd like to see the above go into linux-2.5.
I found a few issues.
- need to call uart_update_timeout
- Maximum delay for console_write (printk) was too short
- one missed icecube to lite5200 name change.
This patch applies on top Sylvain's patch above.
Thanks,
Merged with others bits I fixed.
Already in the -devel tree. I'll push it to the others as soon as I
figure how to do it with bitkeeper ;) ...
Sylvain Munaut
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
@@ -0,0 +1,141 @@+/*+*arch/ppc/boot/simple/mpc52xx_tty.c+*+*MinimalserialfunctionsneededtosendmessagesoutaMPC52xx+*ProgrammableSerialController(PSC).+*+*Author:DaleFarnsworth<dfarnsworth@mvista.com>+*+*2003-2004(c)MontaVista,Software,Inc.Thisfileislicensedunderthe+*termsoftheGNUGeneralPublicLicenseversion2.Thisprogramislicensed+*"as is"withoutanywarrantyofanykind,whetherexpressorimplied.+*/++#include<linux/config.h>+#include<linux/types.h>+#include<asm/uaccess.h>+#include<asm/mpc52xx.h>+#include<asm/mpc52xx_psc.h>+#include<asm/serial.h>+#include<asm/time.h>++#if MPC52xx_PF_CONSOLE_PORT == 0+#define MPC52xx_CONSOLE MPC52xx_PSC1+#define MPC52xx_PSC_CONFIG_SHIFT 0+#elif MPC52xx_PF_CONSOLE_PORT == 1+#define MPC52xx_CONSOLE MPC52xx_PSC2+#define MPC52xx_PSC_CONFIG_SHIFT 4+#elif MPC52xx_PF_CONSOLE_PORT == 2+#define MPC52xx_CONSOLE MPC52xx_PSC3+#define MPC52xx_PSC_CONFIG_SHIFT 8+#else+#error "MPC52xx_PF_CONSOLE_PORT not defined"+#endif++staticstructmpc52xx_psc*psc=(structmpc52xx_psc*)MPC52xx_CONSOLE;++/* The decrementer counts at the system bus clock frequency+*dividedbyfour.Themostaccuratetimebaseisconnectedtothe+*rtc.Wereadthedecrementerchangeduringonertctick(onesecond)+*andmultiplyby4togetthesystembusclockfrequency.+*/+int+mpc52xx_ipbfreq(void)+{+intbusfreq,ipbfreq;+structmpc52xx_rtc*rtc=(structmpc52xx_rtc*)MPC52xx_RTC;+structmpc52xx_cdm*cdm=(structmpc52xx_cdm*)MPC52xx_CDM;+intcurrent_time,previous_time;+inttbl_start,tbl_end;++/* force ipb to 66MHz and PCI to 33MHz */+out_8(&cdm->ipb_clk_sel,1);+out_8(&cdm->pci_clk_sel,1);++previous_time=in_be32(&rtc->time);+while((current_time=in_be32(&rtc->time))==previous_time);+tbl_start=get_tbl();+previous_time=current_time;+while((current_time=in_be32(&rtc->time))==previous_time);+tbl_end=get_tbl();++busfreq=(tbl_end-tbl_start)*4;++ipbfreq=(in_8(&cdm->ipb_clk_sel)&1)?busfreq/2:busfreq;++returnipbfreq;+}++unsignedlong+serial_init(intignored,void*ignored2)+{+structmpc52xx_gpio*gpio=(structmpc52xx_gpio*)MPC52xx_GPIO;+intdivisor;+intmode1;+intmode2;+u32val32;++staticintbeen_here=0;++if(been_here)+return0;++been_here=1;++val32=in_be32(&gpio->port_config);+val32&=~(0x7<<MPC52xx_PSC_CONFIG_SHIFT);+val32|=MPC52xx_GPIO_PSC_CONFIG_UART_WITHOUT_CD+<<MPC52xx_PSC_CONFIG_SHIFT;+out_be32(&gpio->port_config,val32);++out_8(&psc->command,MPC52xx_PSC_RST_TX+|MPC52xx_PSC_RX_DISABLE|MPC52xx_PSC_TX_ENABLE);+out_8(&psc->command,MPC52xx_PSC_RST_RX);++out_be32(&psc->sicr,0x0);+out_be16(&psc->mpc52xx_psc_clock_select,0xdd00);+out_be16(&psc->tfalarm,0xf8);++out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1+|MPC52xx_PSC_RX_ENABLE+|MPC52xx_PSC_TX_ENABLE);++divisor=((mpc52xx_ipbfreq()+/(CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD*16))+1)>>1;++mode1=MPC52xx_PSC_MODE_8_BITS|MPC52xx_PSC_MODE_PARNONE+|MPC52xx_PSC_MODE_ERR;+mode2=MPC52xx_PSC_MODE_ONE_STOP;++out_8(&psc->ctur,divisor>>8);+out_8(&psc->ctlr,divisor);+out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1);+out_8(&psc->mode,mode1);+out_8(&psc->mode,mode2);++return0;/* ignored */+}++void+serial_putc(void*ignored,constcharc)+{+serial_init(0,0);++while(!(in_be16(&psc->mpc52xx_psc_status)&MPC52xx_PSC_SR_TXEMP));+out_8(&psc->mpc52xx_psc_buffer_8,c);+while(!(in_be16(&psc->mpc52xx_psc_status)&MPC52xx_PSC_SR_TXEMP));+}++char+serial_getc(void*ignored)+{+while(!(in_be16(&psc->mpc52xx_psc_status)&MPC52xx_PSC_SR_RXRDY));++returnin_8(&psc->mpc52xx_psc_buffer_8);+}++int+serial_tstc(void*ignored)+{+return(in_be16(&psc->mpc52xx_psc_status)&MPC52xx_PSC_SR_RXRDY)!=0;+}