rtcan: mscan: new OF platform driver for MPC521x and MPC5200
cover rtcan: mscan: new OF platform driver for MPC521x and MPC5200
From: Wolfgang Grandegger <[email protected]>
This patch series adds RT-Socket-CAN support for the MSCAN on the MPC512x from Freescale by introducing a new OF platform driver for both, the MPC521x and MPC5200, while still keeping the old driver for the MPC5200 for compatibility with older kernel versions.
Wolfgang
Wolfgang Grandegger (3):
rtcan: mscan: use tabs for indention and white space cleanup
rtcan: mscan: use proper io accessor functions for register access
rtcan: mscan: new OF platform driver for MPC521x and MPC5200
ksrc/drivers/can/mscan/Kconfig | 21 +- ksrc/drivers/can/mscan/Makefile | 11 +- ksrc/drivers/can/mscan/rtcan_mscan.c | 1245 +++++++++++--------------- ksrc/drivers/can/mscan/rtcan_mscan.h | 38 + ksrc/drivers/can/mscan/rtcan_mscan_mpc52xx.c | 254 ++++++ ksrc/drivers/can/mscan/rtcan_mscan_mpc5xxx.c | 374 ++++++++ ksrc/drivers/can/mscan/rtcan_mscan_proc.c | 184 ++-- ksrc/drivers/can/mscan/rtcan_mscan_regs.h | 74 +- 8 files changed, 1371 insertions(+), 830 deletions(-) create mode 100644 ksrc/drivers/can/mscan/rtcan_mscan.h create mode 100644 ksrc/drivers/can/mscan/rtcan_mscan_mpc52xx.c create mode 100644 ksrc/drivers/can/mscan/rtcan_mscan_mpc5xxx.c
PATCH 1/3 rtcan: mscan: use tabs for indention and white space cleanup
From: Wolfgang Grandegger <[email protected]>
This patch introduces tabs for indention, deletes training white space and corrects some other white space issues.
--- ksrc/drivers/can/mscan/Makefile | 4 +- ksrc/drivers/can/mscan/rtcan_mscan.c | 1226 ++++++++++++++--------------- ksrc/drivers/can/mscan/rtcan_mscan_proc.c | 172 ++-- ksrc/drivers/can/mscan/rtcan_mscan_regs.h | 66 +- 4 files changed, 732 insertions(+), 736 deletions(-)
ksrc/drivers/can/mscan/Makefile +2 -2
@@ -14,9 +14,9 @@ else O_TARGET := built-in.o -obj-$(CONFIG_XENO_DRIVERS_CAN_MSCAN) := xeno_can_mscan.o +obj-$(CONFIG_XENO_DRIVERS_CAN_MSCAN) := xeno_can_mscan.o -list-multi := xeno_can_mscan.o +list-multi := xeno_can_mscan.o xeno_can_mscan-objs := rtcan_mscan.o rtcan_mscan_proc.o
ksrc/drivers/can/mscan/rtcan_mscan.c +610 -616
1,394 lines not on this page · raw message
ksrc/drivers/can/mscan/rtcan_mscan_proc.c +86 -86
196 lines not on this page · raw message
ksrc/drivers/can/mscan/rtcan_mscan_regs.h +34 -32
88 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH 2/3 rtcan: mscan: use proper io accessor functions for register access
From: Wolfgang Grandegger <[email protected]>
--- ksrc/drivers/can/mscan/rtcan_mscan.c | 180 +++++++++++++++------------- ksrc/drivers/can/mscan/rtcan_mscan_proc.c | 48 +++++---- 2 files changed, 123 insertions(+), 105 deletions(-)
ksrc/drivers/can/mscan/rtcan_mscan.c +96 -84
@@ -111,39 +111,41 @@ static inline void rtcan_mscan_rx_interrupt(struct rtcan_device *dev, skb->rb_frame_size =EMPTY_RB_FRAME_SIZE ; - frame->can_dlc = regs->canrxfg.dlr &0x0F ; + frame->can_dlc =in_8 (®s->canrxfg.dlr) &0x0F ;/* If DLC exceeds 8 bytes adjust it to 8 (for the payload size) */ size = (frame->can_dlc >8 ) ?8 : frame->can_dlc; -if (regs->canrxfg.idr[1 ] &MSCAN_BUF_EXTENDED ) { - frame->can_id = ((regs->canrxfg.idr[0 ] <<21 ) | - ((regs->canrxfg.idr[1 ] &0xE0 ) <<13 ) | - ((regs->canrxfg.idr[1 ] &0x07 ) <<15 ) | - (regs->canrxfg.idr[4 ] <<7 ) | - (regs->canrxfg.idr[5 ] >>1 )); +if (in_8 (®s->canrxfg.idr[1 ]) &MSCAN_BUF_EXTENDED ) { + frame->can_id = ((in_8 (®s->canrxfg.idr[0 ]) <<21 ) | + ((in_8 (®s->canrxfg.idr[1 ]) &0xE0 ) <<13 ) | + ((in_8 (®s->canrxfg.idr[1 ]) &0x07 ) <<15 ) | + (in_8 (®s->canrxfg.idr[4 ]) <<7 ) | + (in_8 (®s->canrxfg.idr[5 ]) >>1 )); frame->can_id |=CAN_EFF_FLAG ; -if ((regs->canrxfg.idr[5 ] &MSCAN_BUF_EXT_RTR )) { +if ((in_8 (®s->canrxfg.idr[5 ]) &MSCAN_BUF_EXT_RTR )) { frame->can_id |=CAN_RTR_FLAG ; }else {for (i =0 ; i < size; i++) frame->data[i] = - regs->canrxfg.dsr[i + (i /2 ) *2 ]; +in_8 (®s->canrxfg.dsr[i + + (i /2 ) *2 ]); skb->rb_frame_size += size; } }else { - frame->can_id = ((regs->canrxfg.idr[0 ] <<3 ) | - (regs->canrxfg.idr[1 ] >>5 )); + frame->can_id = ((in_8 (®s->canrxfg.idr[0 ]) <<3 ) | + (in_8 (®s->canrxfg.idr[1 ]) >>5 )); -if ((regs->canrxfg.idr[1 ] &MSCAN_BUF_STD_RTR )) { +if ((in_8 (®s->canrxfg.idr[1 ]) &MSCAN_BUF_STD_RTR )) { frame->can_id |=CAN_RTR_FLAG ; }else {for (i =0 ; i < size; i++) frame->data[i] = - regs->canrxfg.dsr[i + (i /2 ) *2 ]; +in_8 (®s->canrxfg.dsr[i + + (i /2 ) *2 ]); skb->rb_frame_size += size; } }
@@ -193,7 +195,7 @@ static inline void rtcan_mscan_err_interrupt(struct rtcan_device *dev, frame->can_id |=CAN_ERR_BUSOFF ; dev->state =CAN_STATE_BUS_OFF ;/* Disable receiver interrupts */ - regs->canrier =0 ; +out_8 (®s->canrier,0 );/* Wake up waiting senders */ rtdm_sem_destroy (&dev->tx_sem);break ;
@@ -239,13 +241,14 @@ static int rtcan_mscan_interrupt(rtdm_irq_t *irq_handle)rtdm_lock_get (&dev->device_lock); - canrflg = regs->canrflg; + canrflg =in_8 (®s->canrflg); ret =RTDM_IRQ_HANDLED ;/* Transmit Interrupt? */ -if ((regs->cantier &MSCAN_TXIE0 ) && (regs->cantflg &MSCAN_TXE0 )) { - regs->cantier =0 ; +if ((in_8 (®s->cantier) &MSCAN_TXIE0 ) && + (in_8 (®s->cantflg) &MSCAN_TXE0 )) { +out_8 (®s->cantier,0 );/* Wake up a sender */ rtdm_sem_up (&dev->tx_sem);
@@ -306,7 +309,7 @@ static int rtcan_mscan_interrupt(rtdm_irq_t *irq_handle)* Only do so for the receiver interrupts. */ if (canrflg) - regs->canrflg = canrflg; +out_8 (®s->canrflg, canrflg);if (!recv_lock_free) {rtdm_lock_put (&rtcan_socket_lock);
@@ -343,8 +346,7 @@ static int rtcan_mscan_mode_stop(struct rtcan_device *dev,int ret =0 ;int rinit =0 ;can_state_t state; -volatile struct mscan_regs *regs = - (struct mscan_regs *)dev->base_addr; +struct mscan_regs *regs = (struct mscan_regs *)dev->base_addr;u8 reg; state = dev->state;
@@ -353,10 +355,10 @@ static int rtcan_mscan_mode_stop(struct rtcan_device *dev, goto out;/* Switch to sleep mode */ - regs->canctl0 |=MSCAN_SLPRQ ; - regs->canctl0 |=MSCAN_INITRQ ; +setbits8 (®s->canctl0,MSCAN_SLPRQ ); +setbits8 (®s->canctl0,MSCAN_INITRQ ); - reg = regs->canctl1; + reg =in_8 (®s->canctl1);while (!(reg &MSCAN_SLPAK ) || !(reg &MSCAN_INITAK )) {if (likely (lock_ctx !=NULL ))
@@ -366,7 +368,7 @@ static int rtcan_mscan_mode_stop(struct rtcan_device *dev,if (likely (lock_ctx !=NULL ))rtdm_lock_get_irqsave (&dev->device_lock, *lock_ctx); rinit++; - reg = regs->canctl1; + reg =in_8 (®s->canctl1); }/* Volatile state could have changed while we slept busy. */
@@ -400,8 +402,7 @@ static int rtcan_mscan_mode_start(struct rtcan_device *dev, {int ret =0 , retries =0 ;can_state_t state; -volatile struct mscan_regs *regs = - (struct mscan_regs *)dev->base_addr; +struct mscan_regs *regs = (struct mscan_regs *)dev->base_addr;/* We won't forget that state in the device structure is volatile and * access to it will not be optimized by the compiler. So ... */
@@ -421,21 +422,21 @@ static int rtcan_mscan_mode_start(struct rtcan_device *dev,rtdm_sem_init (&dev->tx_sem,1 );if ((dev->ctrl_mode &CAN_CTRLMODE_LISTENONLY )) { - regs->canctl1 |=MSCAN_LISTEN ; +setbits8 (®s->canctl1,MSCAN_LISTEN ); }else { - regs->canctl1 &= ~MSCAN_LISTEN ; +clrbits8 (®s->canctl1,MSCAN_LISTEN ); }if ((dev->ctrl_mode &CAN_CTRLMODE_LOOPBACK )) { - regs->canctl1 |=MSCAN_LOOPB ; +setbits8 (®s->canctl1,MSCAN_LOOPB ); }else { - regs->canctl1 &= ~MSCAN_LOOPB ; +clrbits8 (®s->canctl1,MSCAN_LOOPB ); }/* Switch to normal mode */ - regs->canctl0 &= ~MSCAN_INITRQ ; - regs->canctl0 &= ~MSCAN_SLPRQ ; -while ((regs->canctl1 &MSCAN_INITAK ) || - (regs->canctl1 &MSCAN_SLPAK )) { +clrbits8 (®s->canctl0,MSCAN_INITRQ ); +clrbits8 (®s->canctl0,MSCAN_SLPRQ ); +while ((in_8 (®s->canctl1) &MSCAN_INITAK ) || + (in_8 (®s->canctl1) &MSCAN_SLPAK )) {if (likely (lock_ctx !=NULL ))rtdm_lock_put_irqrestore (&dev->device_lock, *lock_ctx);
@@ -447,13 +448,13 @@ static int rtcan_mscan_mode_start(struct rtcan_device *dev, retries++; }/* Enable interrupts */ - regs->canrier |=MSCAN_RIER ; +setbits8 (®s->canrier,MSCAN_RIER );break ;case CAN_STATE_BUS_OFF :/* Trigger bus-off recovery */ - regs->canrier =MSCAN_RIER ; +out_8 (®s->canrier,MSCAN_RIER );/* Set up sender "mutex" */ rtdm_sem_init (&dev->tx_sem,1 );/* Set error active state */
@@ -497,8 +498,8 @@ int rtcan_mscan_set_bit_time(struct rtcan_device *dev,return -EINVAL ; } - regs->canbtr0 = btr0; - regs->canbtr1 = btr1; +out_8 (®s->canbtr0, btr0); +out_8 (®s->canbtr1, btr1);rtdm_printk ("%s: btr0=0x%02x btr1=0x%02x\n" , dev->name, btr0, btr1);
@@ -544,10 +545,11 @@ int rtcan_mscan_set_mode(struct rtcan_device *dev,/* Let's take a nap. (Now I REALLY understand * the meaning of interrupts ...) */ - regs->canrier =0 ; - regs->cantier =0 ; - regs->canctl0 |=MSCAN_SLPRQ /*| MSCAN_INITRQ*/ |MSCAN_WUPE ; -while (!(regs->canctl1 &MSCAN_SLPAK )) { +out_8 (®s->canrier,0 ); +out_8 (®s->cantier,0 ); +setbits8 (®s->canctl0, +MSCAN_SLPRQ /*| MSCAN_INITRQ*/ |MSCAN_WUPE ); +while (!(in_8 (®s->canctl1) &MSCAN_SLPAK )) {rtdm_lock_put_irqrestore (&dev->device_lock, *lock_ctx);/* Busy sleep 1 microsecond */ rtdm_task_busy_sleep (1000 );
@@ -556,8 +558,8 @@ int rtcan_mscan_set_mode(struct rtcan_device *dev,break ; }rtdm_printk ("Fallen asleep after %d tries.\n" , retries); - regs->canctl0 &= ~MSCAN_INITRQ ; -while ((regs->canctl1 &MSCAN_INITAK )) { +clrbits8 (®s->canctl0,MSCAN_INITRQ ); +while ((in_8 (®s->canctl1) &MSCAN_INITAK )) {rtdm_lock_put_irqrestore (&dev->device_lock, *lock_ctx);/* Busy sleep 1 microsecond */ rtdm_task_busy_sleep (1000 );
@@ -566,7 +568,7 @@ int rtcan_mscan_set_mode(struct rtcan_device *dev,break ; }rtdm_printk ("Back to normal after %d tries.\n" , retries); - regs->canrier =MSCAN_WUPIE ; +out_8 (®s->canrier,MSCAN_WUPIE ); mode_sleep_out: dev->state = state;
@@ -596,16 +598,15 @@ static int rtcan_mscan_start_xmit(struct rtcan_device *dev, can_frame_t *frame)unsigned char size;/* Content of frame information register */ unsigned char dlc; -struct mscan_regs *regs = (struct mscan_regs *)dev->base_addr;/* Is TX buffer empty? */ -if (!(regs->cantflg &MSCAN_TXE0 )) { +if (!(in_8 (®s->cantflg) &MSCAN_TXE0 )) {rtdm_printk ("rtcan_mscan_start_xmit: TX buffer not empty" );return -EIO ; }/* Select the buffer we've found. */ - regs->cantbsel =MSCAN_TXE0 ; +out_8 (®s->cantbsel,MSCAN_TXE0 );/* Get DLC and ID */ dlc = frame->can_dlc;
@@ -615,51 +616,51 @@ static int rtcan_mscan_start_xmit(struct rtcan_device *dev, can_frame_t *frame) id = frame->can_id;if (frame->can_id &CAN_EFF_FLAG ) { - regs->cantxfg.idr[0 ] = (id &0x1fe00000 ) >>21 ; - regs->cantxfg.idr[1 ] = (id &0x001c0000 ) >>13 ; - regs->cantxfg.idr[1 ] |= (id &0x00038000 ) >>15 ; - regs->cantxfg.idr[1 ] |=0x18 ;/* set SRR and IDE bits */ +out_8 (®s->cantxfg.idr[0 ], (id &0x1fe00000 ) >>21 ); +out_8 (®s->cantxfg.idr[1 ], ((id &0x001c0000 ) >>13 ) | + ((id &0x00038000 ) >>15 ) | +0x18 );/* set SRR and IDE bits */ - regs->cantxfg.idr[4 ] = (id &0x00007f80 ) >>7 ; - regs->cantxfg.idr[5 ] = (id &0x0000007f ) <<1 ; +out_8 (®s->cantxfg.idr[4 ], (id &0x00007f80 ) >>7 ); +out_8 (®s->cantxfg.idr[5 ], (id &0x0000007f ) <<1 );/* RTR? */ if (frame->can_id &CAN_RTR_FLAG ) - regs->cantxfg.idr[5 ] |=0x1 ; +setbits8 (®s->cantxfg.idr[5 ],0x1 );else { - regs->cantxfg.idr[5 ] &= ~0x1 ; +clrbits8 (®s->cantxfg.idr[5 ],0x1 );/* No RTR, write data bytes */ for (i =0 ; i < size; i++) - regs->cantxfg.dsr[i + (i /2 ) *2 ] = - frame->data[i]; +out_8 (®s->cantxfg.dsr[i + (i /2 ) *2 ], + frame->data[i]); } }else {/* Send standard frame */ - regs->cantxfg.idr[0 ] = (id &0x000007f8 ) >>3 ; - regs->cantxfg.idr[1 ] = (id &0x00000007 ) <<5 ; +out_8 (®s->cantxfg.idr[0 ], (id &0x000007f8 ) >>3 ); +out_8 (®s->cantxfg.idr[1 ], (id &0x00000007 ) <<5 );/* RTR? */ if (frame->can_id &CAN_RTR_FLAG ) - regs->cantxfg.idr[1 ] |=0x10 ; +setbits8 (®s->cantxfg.idr[1 ],0x10 );else { - regs->cantxfg.idr[1 ] &= ~0x10 ; +clrbits8 (®s->cantxfg.idr[1 ],0x10 );/* No RTR, write data bytes */ for (i =0 ; i < size; i++) - regs->cantxfg.dsr[i + (i /2 ) *2 ] = - frame->data[i]; +out_8 (®s->cantxfg.dsr[i + (i /2 ) *2 ], + frame->data[i]); } } - regs->cantxfg.dlr = frame->can_dlc; - regs->cantxfg.tbpr =0 ;/* all messages have the same prio */ +out_8 (®s->cantxfg.dlr, frame->can_dlc); +out_8 (®s->cantxfg.tbpr,0 );/* all messages have the same prio */ /* Trigger transmission. */ - regs->cantflg =MSCAN_TXE0 ; +out_8 (®s->cantflg,MSCAN_TXE0 );/* Enable interrupt. */ - regs->cantier |=MSCAN_TXIE0 ; +setbits8 (®s->cantier,MSCAN_TXIE0 );return 0 ; }
@@ -678,26 +679,35 @@ static inline void __init mscan_chip_config(struct mscan_regs *regs) {/* Choose IP bus as clock source. */ - regs->canctl1 |=MSCAN_CLKSRC ; - regs->canctl1 &= ~MSCAN_LISTEN ; +setbits8 (®s->canctl1,MSCAN_CLKSRC ); +clrbits8 (®s->canctl1,MSCAN_LISTEN );/* Configure MSCAN to accept all incoming messages. */ - regs->canidar0 = regs->canidar1 =0x00 ; - regs->canidar2 = regs->canidar3 =0x00 ; - regs->canidmr0 = regs->canidmr1 =0xFF ; - regs->canidmr2 = regs->canidmr3 =0xFF ; - regs->canidar4 = regs->canidar5 =0x00 ; - regs->canidar6 = regs->canidar7 =0x00 ; - regs->canidmr4 = regs->canidmr5 =0xFF ; - regs->canidmr6 = regs->canidmr7 =0xFF ; - regs->canidac &= ~(MSCAN_IDAM0 |MSCAN_IDAM1 ); +out_8 (®s->canidar0,0x00 ); +out_8 (®s->canidar1,0x00 ); +out_8 (®s->canidar2,0x00 ); +out_8 (®s->canidar3,0x00 ); +out_8 (®s->canidmr0,0xFF ); +out_8 (®s->canidmr1,0xFF ); +out_8 (®s->canidmr2,0xFF ); +out_8 (®s->canidmr3,0xFF ); +out_8 (®s->canidar4,0x00 ); +out_8 (®s->canidar5,0x00 ); +out_8 (®s->canidar6,0x00 ); +out_8 (®s->canidar7,0x00 ); +out_8 (®s->canidmr4,0xFF ); +out_8 (®s->canidmr5,0xFF ); +out_8 (®s->canidmr6,0xFF ); +out_8 (®s->canidmr7,0xFF ); +clrbits8 (®s->canidac,MSCAN_IDAM0 |MSCAN_IDAM1 ); }static inline void __init mscan_gpio_config (void ) {struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5xxx_GPIO;int can_to_psc2 =-1 ; +u32 port_config;#if defined(CONFIG_XENO_DRIVERS_CAN_MSCAN_ALT ) can_to_psc2 =0 ;
@@ -725,15 +735,17 @@ static inline void __init mscan_gpio_config(void)return ; } + port_config =in_be32 (&gpio->port_config);if (can_to_psc2) { - gpio->port_config &= ~0x10000070 ; - gpio->port_config |=0x00000010 ; + port_config &= ~0x10000070 ; + port_config |=0x00000010 ;printk ("%s: CAN 1 and 2 routed to PSC2 pins\n" ,RTCAN_DRV_NAME ); }else { - gpio->port_config |=0x10000000 ; + port_config |=0x10000000 ;printk ("%s: CAN 1 routed to I2C1 pins and CAN2 to TMR01 pins\n" ,RTCAN_DRV_NAME ); } +out_be32 (&gpio->port_config, port_config); }static inline int mscan_get_config (unsigned long *addr,unsigned int *irq)
@@ -795,7 +807,7 @@ int __init rtcan_mscan_init_one(int idx, unsigned long addr, int irq) regs = (struct mscan_regs *)dev->base_addr;/* Enable MSCAN module. */ - regs->canctl1 |=MSCAN_CANE ; +setbits8 (®s->canctl1,MSCAN_CANE );udelay (100 );/* Set dummy state for following call */
@@ -847,7 +859,7 @@ out_irq_free: out_iounmap:/* Disable MSCAN module. */ - regs->canctl1 &= ~MSCAN_CANE ; +clrbits8 (®s->canctl1,MSCAN_CANE );iounmap ((void *)dev->base_addr); out_dev_free:
ksrc/drivers/can/mscan/rtcan_mscan_proc.c +27 -21
74 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH 3/3 rtcan: mscan: new OF platform driver for MPC521x and MPC5200
From: Wolfgang Grandegger <[email protected]>
This patch introduces support for the MPC512x from Freescale. To re-use the driver initialization code from the new "mpc5xxx_can" driver from the mainline kernel, the old initialization code for the MPC5200 from "rtcan_mscan.c" has been moved to "rtcan_mscan_mpc52xx.c", mainly for backward compatibility with older kernel version. If required, it can be selected via Kconfig option. The new file "rtcan_mscan_mpc5xxx.c" adds OF platform driver support for the MPC5200 *and* the MPC512x. Port and clock selection is done as described for the mpc5xxx_can mainline driver in "Documentation/powerpc/dts-bindings/fsl/can.txt".
--- ksrc/drivers/can/mscan/Kconfig | 21 ++- ksrc/drivers/can/mscan/Makefile | 7 +- ksrc/drivers/can/mscan/rtcan_mscan.c | 255 +++--------------- ksrc/drivers/can/mscan/rtcan_mscan.h | 38 +++ ksrc/drivers/can/mscan/rtcan_mscan_mpc52xx.c | 254 +++++++++++++++++ ksrc/drivers/can/mscan/rtcan_mscan_mpc5xxx.c | 374 ++++++++++++++++++++++++++ ksrc/drivers/can/mscan/rtcan_mscan_proc.c | 6 +- ksrc/drivers/can/mscan/rtcan_mscan_regs.h | 8 + 8 files changed, 745 insertions(+), 218 deletions(-) create mode 100644 ksrc/drivers/can/mscan/rtcan_mscan.h create mode 100644 ksrc/drivers/can/mscan/rtcan_mscan_mpc52xx.c create mode 100644 ksrc/drivers/can/mscan/rtcan_mscan_mpc5xxx.c
ksrc/drivers/can/mscan/Kconfig +19 -2
@@ -1,7 +1,22 @@ config XENO_DRIVERS_CAN_MSCAN - depends on XENO_DRIVERS_CAN && PPC_MPC52xx - tristate "MSCAN driver for MPC52xx" + depends on XENO_DRIVERS_CAN && (PPC_MPC52xx || PPC_MPC512x) + tristate "MSCAN driver for MPC52xx and MPC512x" default n + help + + This driver is for the MSCAN on the MPC5200 and MPC512x processor + from Freescale. + +config XENO_DRIVERS_CAN_MSCAN_OLD + depends on XENO_DRIVERS_CAN_MSCAN && PPC_MPC52xx + bool "Use old MSCAN driver for old kernel version" + default n + help + + For backward compatibility with older kernel versions, you may + want to select the old MSCAN driver for the MPC5200. + +if XENO_DRIVERS_CAN_MSCAN_OLD config XENO_DRIVERS_CAN_MSCAN_1 depends on XENO_DRIVERS_CAN_MSCAN
@@ -41,3 +56,5 @@ config XENO_DRIVERS_CAN_MSCAN_PSC2 endchoice +endif +
ksrc/drivers/can/mscan/Makefile +6 -1
@@ -7,6 +7,11 @@ EXTRA_CFLAGS += -D__IN_XENOMAI__ -Iinclude/xenomai -Idrivers/xenomai/can -Idrive obj-$(CONFIG_XENO_DRIVERS_CAN_MSCAN) += xeno_can_mscan.o xeno_can_mscan-y := rtcan_mscan.o rtcan_mscan_proc.o +ifdef CONFIG_XENO_DRIVERS_CAN_MSCAN_OLD +xeno_can_mscan-y += rtcan_mscan_mpc52xx.o +else +xeno_can_mscan-y += rtcan_mscan_mpc5xxx.o +endif else
@@ -18,7 +23,7 @@ obj-$(CONFIG_XENO_DRIVERS_CAN_MSCAN) := xeno_can_mscan.o list-multi := xeno_can_mscan.o -xeno_can_mscan-objs := rtcan_mscan.o rtcan_mscan_proc.o +xeno_can_mscan-objs := rtcan_mscan.o rtcan_mscan_proc.o rtcan_mscan_mpc52xx.o export-objs := $(xeno_can_mscan-objs)
ksrc/drivers/can/mscan/rtcan_mscan.c +41 -214
328 lines not on this page · raw message
ksrc/drivers/can/mscan/rtcan_mscan.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Copyright (C) 2009 Wolfgang Grandegger <[email protected]> +* +* 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. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef __RTCAN_MSCAN_H_ +#define __RTCAN_MSCAN_H_ + +#define RTCAN_DEV_NAME "rtcan%d" +#define RTCAN_DRV_NAME "rtcan_mscan" + +/* MSCAN type variants */ +enum { +MSCAN_TYPE_MPC5200 , +MSCAN_TYPE_MPC5121 +}; + +extern int rtcan_mscan_register (struct rtcan_device *dev,int irq, +int mscan_clksrc); +extern int rtcan_mscan_unregister (struct rtcan_device *dev); + +extern int rtcan_mscan_create_proc (struct rtcan_device * dev); +extern void rtcan_mscan_remove_proc (struct rtcan_device * dev); + +#endif /* __RTCAN_MSCAN_H_ */
ksrc/drivers/can/mscan/rtcan_mscan_mpc52xx.c new file +254 -0
254 lines not on this page · raw message
ksrc/drivers/can/mscan/rtcan_mscan_mpc5xxx.c new file +374 -0
374 lines not on this page · raw message
ksrc/drivers/can/mscan/rtcan_mscan_proc.c +5 -1
@@ -38,9 +38,11 @@ static int rtcan_mscan_proc_regs(char *buf, char **start, off_t offset, {struct rtcan_device *dev = (struct rtcan_device *)data;struct mscan_regs *regs = (struct mscan_regs *)dev->base_addr; +#ifdef CONFIG_XENO_DRIVERS_CAN_MSCAN_OLD struct mpc5xxx_gpio *gpio = (struct mpc5xxx_gpio *)MPC5xxx_GPIO; -u8 canctl0, canctl1;u32 port_config; +#endif +u8 canctl0, canctl1;RTCAN_PROC_PRINT_VARS (80 );if (!RTCAN_PROC_PRINT ("MSCAN registers at %p\n" , regs))
@@ -98,6 +100,7 @@ static int rtcan_mscan_proc_regs(char *buf, char **start, off_t offset, !RTCAN_PROC_PRINT(MSCAN_REG_ARGS(canidmr7))) goto done; +#ifdef CONFIG_XENO_DRIVERS_CAN_MSCAN_OLD if (!RTCAN_PROC_PRINT ("GPIO registers\n" )) goto done; port_config =in_be32 (&gpio->port_config);
@@ -107,6 +110,7 @@ static int rtcan_mscan_proc_regs(char *buf, char **start, off_t offset, (port_config & 0x70) == 0x10 ? "CAN1/2 on PSC2 pins": "MSCAN1/2 not routed"))) goto done; +#endif done:RTCAN_PROC_PRINT_DONE ;
ksrc/drivers/can/mscan/rtcan_mscan_regs.h +8 -0
@@ -25,6 +25,7 @@#ifndef __RTCAN_MSCAN_REGS_H_#define __RTCAN_MSCAN_REGS_H_ +#ifdef CONFIG_XENO_DRIVERS_CAN_MSCAN_OLD #if LINUX_VERSION_CODE >KERNEL_VERSION (2 ,6 ,20 )#include <sysdev/fsl_soc.h> #if LINUX_VERSION_CODE >KERNEL_VERSION (2 ,6 ,22 )
@@ -60,6 +61,7 @@ static inline void __iomem *mpc5xxx_gpio_find_and_map(void)#define MPC5xxx_GPIO MPC52xx_VA(MPC52xx_GPIO_OFFSET)#define mpc5xxx_gpio mpc52xx_gpio#endif +#endif #define MSCAN_CAN1_ADDR (MSCAN_MBAR + 0x0900)/* MSCAN Module 1 */ #define MSCAN_CAN2_ADDR (MSCAN_MBAR + 0x0980)/* MSCAN Module 2 */
@@ -200,6 +202,12 @@ struct mscan_regs {struct mscan_msgbuf cantxfg;/* MSCAN + 0x60 */ /* Foreground transmit buffer */ }; +/* Clock source selection +*/ +#define MSCAN_CLKSRC_BUS 0 +#define MSCAN_CLKSRC_XTAL MSCAN_CLKSRC +#define MSCAN_CLKSRC_IPS MSCAN_CLKSRC +/* Message type access macros. */ #define MSCAN_BUF_STD_RTR 0x10
Signature · 1 line
1.6.2.5
PATCH 3/3 rtcan: mscan: new OF platform driver for MPC521x and MPC5200
pdir=../send-rtcan-mscan-mpc5xxx/
sprefix="PATCH xenomai-2.5" commitid=b197fe0f370d92ee1838b370fbf927ca50a0e573 subject="rtcan: mscan: new OF platform driver for MPC521x and MPC5200" blurb="\
This patch series adds RT-Socket-CAN support for the MSCAN on the MPC512x\\
from Freescale by introducing a new OF platform driver for both, the\\
MPC521x and MPC5200, while still keeping the old driver for the MPC5200\\
for compatibility with older kernel versions.\\
\\
Wolfgang"
rm -f $pdir/*.patch
mkdir $pdir
opt="--dry-run"
test "$1" = "send" && opt=""
git format-patch -n -o $pdir --cover-letter --subject-prefix="$sprefix" \
$commitid
mv $pdir/0000-cover-letter.patch /tmp/0000-cover-letter.patch sed "
s/\*\*\* SUBJECT HERE \*\*\*/$subject/
s/\*\*\* BLURB HERE \*\*\*/$blurb/
" /tmp/0000-cover-letter.patch > $pdir/0000-cover-letter.patch
echo "=====================================================================" cat $pdir/0000-cover-letter.patch
echo "====================================================================="
opt="--dry-run"
test "$1" = "send" && opt=""
git format-patch -o $pdir --subject-prefix="$sprefix" $commitid
echo "opt=$opt"
git send-email $opt \
--to "[email protected]" \
--from="Wolfgang Grandegger <[email protected]>" \
$pdirPATCH 3/3 rtcan: mscan: new OF platform driver for MPC521x and MPC5200
pdir=../send-rtcan-mscan-mpc5xxx/
sprefix="PATCH xenomai-2.5" commitid=b197fe0f370d92ee1838b370fbf927ca50a0e573 subject="rtcan: mscan: new OF platform driver for MPC521x and MPC5200" blurb="\
This patch series adds RT-Socket-CAN support for the MSCAN on the MPC512x from Freescale by introducing a new OF platform driver for both, the\\
MPC521x and MPC5200, while still keeping the old driver for the MPC5200\\
for compatibility with older kernel versions\\
\\
Wolfgang"
rm -f $pdir/*.patch
mkdir $pdir
opt="--dry-run"
test "$1" = "send" && opt=""
git format-patch -n -o $pdir --cover-letter --subject-prefix="$sprefix" \
$commitid
mv $pdir/0000-cover-letter.patch /tmp/0000-cover-letter.patch sed "
s/\*\*\* SUBJECT HERE \*\*\*/$subject/
s/\*\*\* BLURB HERE \*\*\*/$blurb/
" /tmp/0000-cover-letter.patch > $pdir/0000-cover-letter.patch
echo "=====================================================================" cat $pdir/0000-cover-letter.patch
echo "====================================================================="
opt="--dry-run"
test "$1" = "send" && opt=""
git format-patch -o $pdir --subject-prefix="$sprefix" $commitid
echo "opt=$opt"
git send-email $opt \
--to "[email protected]" \
--from="Wolfgang Grandegger <[email protected]>" \
$pdirQuoted 33 lines · Wolfgang Grandegger
pdir=../send-rtcan-mscan-mpc5xxx/
sprefix="PATCH xenomai-2.5" commitid=b197fe0f370d92ee1838b370fbf927ca50a0e573 subject="rtcan: mscan: new OF platform driver for MPC521x and MPC5200" blurb="\
This patch series adds RT-Socket-CAN support for the MSCAN on the MPC512x\\
from Freescale by introducing a new OF platform driver for both, the\\
MPC521x and MPC5200, while still keeping the old driver for the MPC5200\\
for compatibility with older kernel versions.\\
\\
Wolfgang"rm -f $pdir/*.patch
mkdir $pdir
opt="--dry-run"
test "$1" = "send" && opt=""git format-patch -n -o $pdir --cover-letter --subject-prefix="$sprefix" \
$commitidmv
$pdir/0000-cover-letter.patch/tmp/0000-cover-letter.patchsed "
s/\*\*\* SUBJECT HERE \*\*\*/$subject/
s/\*\*\* BLURB HERE \*\*\*/$blurb/
"/tmp/0000-cover-letter.patch>$pdir/0000-cover-letter.patchecho "=====================================================================" cat
$pdir/0000-cover-letter.patch
echo "====================================================================="opt="--dry-run"
test "$1" = "send" && opt=""
Quoted 7 lines
git format-patch -o $pdir --subject-prefix="$sprefix" $commitid
echo "opt=$opt"
git send-email $opt \ --to "[email protected]" \ --from="Wolfgang Grandegger <[email protected]>" \ $pdir
s/$pdir/$pdir/*.patch/
Grrr, due to that mistake in my git-patch-prepare-and-send script, the script file (and backup) has also been sent to the list as well. Please ignore the last two patch. Sorry for the noise
Wolfgang.
Quoted 42 lines · Wolfgang Grandegger
Quoted 33 lines · Wolfgang Grandegger
pdir=../send-rtcan-mscan-mpc5xxx/
sprefix="PATCH xenomai-2.5" commitid=b197fe0f370d92ee1838b370fbf927ca50a0e573 subject="rtcan: mscan: new OF platform driver for MPC521x and MPC5200" blurb="\
This patch series adds RT-Socket-CAN support for the MSCAN on the MPC512x\\
from Freescale by introducing a new OF platform driver for both, the\\
MPC521x and MPC5200, while still keeping the old driver for the MPC5200\\
for compatibility with older kernel versions.\\
\\
Wolfgang"rm -f $pdir/*.patch
mkdir $pdir
opt="--dry-run"
test "$1" = "send" && opt=""git format-patch -n -o $pdir --cover-letter --subject-prefix="$sprefix" \
$commitidmv
$pdir/0000-cover-letter.patch/tmp/0000-cover-letter.patchsed "
s/\*\*\* SUBJECT HERE \*\*\*/$subject/
s/\*\*\* BLURB HERE \*\*\*/$blurb/
"/tmp/0000-cover-letter.patch>$pdir/0000-cover-letter.patchecho "=====================================================================" cat
$pdir/0000-cover-letter.patch
echo "====================================================================="opt="--dry-run"
test "$1" = "send" && opt=""Quoted 7 lines
git format-patch -o $pdir --subject-prefix="$sprefix" $commitid
echo "opt=$opt"
git send-email $opt \ --to "[email protected]" \ --from="Wolfgang Grandegger <[email protected]>" \ $pdir
Quoted 5 lines
s/$pdir/$pdir/*.patch/
Grrr, due to that mistake in my git-patch-prepare-and-send script, the script file (and backup) has also been sent to the list as well. Please ignore the last two patch. Sorry for the noise
Hi Wolfgang,
Would you want a git tree on Xenomai server? This way you could use git push and git-request-pull ?
There is not much point for me in proof-reading your patches, since I do not know much about rt-socket-can.
Regards.
Signature · 1 line
Gilles.
Hi Gilles,
Gilles Chanteperdrix wrote:
...
Quoted 2 lines
Would you want a git tree on Xenomai server? This way you could use git push and git-request-pull ?
Well, seems a bit overkill to me at the moment. There are only a few patches per year related to RT-Socket-CAN. If you think it does easy your work, please let me know.
Quoted 2 lines
There is not much point for me in proof-reading your patches, since I do not know much about rt-socket-can.
No problem. I'm happy if you just apply it ;-).
Thanks,
Wolfgang.
Quoted 6 lines · Wolfgang Grandegger
From: Wolfgang Grandegger <[email protected]>
This patch series adds RT-Socket-CAN support for the MSCAN on the MPC512x from Freescale by introducing a new OF platform driver for both, the MPC521x and MPC5200, while still keeping the old driver for the MPC5200 for compatibility with older kernel versions.
Hi Wolfgang,
there seems to be something missing, because I get a compilation error on lite-5200:
http://sisyphus.hd.free.fr/~gilles/bx/#powerpc
Regards.
Signature · 1 line
Gilles.
Quoted 8 lines · Gilles Chanteperdrix
Quoted 6 lines · Wolfgang Grandegger
From: Wolfgang Grandegger <[email protected]>
This patch series adds RT-Socket-CAN support for the MSCAN on the MPC512x from Freescale by introducing a new OF platform driver for both, the MPC521x and MPC5200, while still keeping the old driver for the MPC5200 for compatibility with older kernel versions.
Quoted 5 lines
Hi Wolfgang,
there seems to be something missing, because I get a compilation error on lite-5200:
http://sisyphus.hd.free.fr/~gilles/bx/#powerpc
Well, I obviously did not test the driver with old versions of the Linux kernel, sorry. For 2.6.29 and 2.6.30 the following patch should fix the build:
(quoted diff) +0 -0
b/ksrc/drivers/can/mscan/rtcan_mscan_mpc5xxx.c
index 48abd89..47e34b6 100644
ksrc/drivers/can/mscan/rtcan_mscan_mpc5xxx.c +0 -0
@@ -76,7 +76,11 @@ static u32 __devinit mpc52xx_can_get_clock(struct
of_device *ofdev,
else
*mscan_clksrc = MSCAN_CLKSRC_XTAL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
+ freq = mpc52xx_find_ipb_freq(ofdev->node);
+#else
freq = mpc5xxx_get_bus_frequency(ofdev->node);
+#endif
if (!freq)
return 0;
For 2.4 I will have a close look now.
This proves, your regression test build tool is really useful.
Thanks,
Wolfgang.
Quoted 8 lines · Wolfgang Grandegger
Quoted 7 lines · Gilles Chanteperdrix
Quoted 6 lines · Wolfgang Grandegger
From: Wolfgang Grandegger <[email protected]>
This patch series adds RT-Socket-CAN support for the MSCAN on the MPC512x from Freescale by introducing a new OF platform driver for both, the MPC521x and MPC5200, while still keeping the old driver for the MPC5200 for compatibility with older kernel versions.
Quoted 8 lines
Quoted 5 lines
Hi Wolfgang,
there seems to be something missing, because I get a compilation error on lite-5200:
http://sisyphus.hd.free.fr/~gilles/bx/#powerpcWell, I obviously did not test the driver with old versions of the Linux kernel, sorry.
No problem, that is what the build test is for.
Quoted 1 line
For 2.6.29 and 2.6.30 the following patch should fix the build:
Ok. I applied a slightly different modification (fixing in wrappers.h). I am waiting for your fix for 2.4 for pushing.
Quoted 3 lines
For 2.4 I will have a close look now.
This proves, your regression test build tool is really useful.
That is, if you assume people in the wild are trying older versions...
Signature · 1 line
Gilles.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 22 lines · Wolfgang Grandegger
Hi Gilles
Quoted 19 lines · Gilles Chanteperdrix
Quoted 8 lines · Wolfgang Grandegger
Quoted 7 lines · Gilles Chanteperdrix
Quoted 6 lines · Wolfgang Grandegger
From: Wolfgang Grandegger <[email protected]>
This patch series adds RT-Socket-CAN support for the MSCAN on the MPC512x from Freescale by introducing a new OF platform driver for both, the MPC521x and MPC5200, while still keeping the old driver for the MPC5200 for compatibility with older kernel versions.
Quoted 7 lines
Quoted 5 lines
Hi Wolfgang,
there seems to be something missing, because I get a compilation error on lite-5200:
http://sisyphus.hd.free.fr/~gilles/bx/#powerpcWell, I obviously did not test the driver with old versions of the Linux kernel, sorry.
No problem, that is what the build test is for.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
For 2.6.29 and 2.6.30 the following patch should fix the build:
Ok. I applied a slightly different modification (fixing in
wrappers.h). I am waiting for your fix for 2.4 for pushing.See patch below. It will contain your fixes in
wrappers.h. I will do some final testing on real hardware on monday.
All green, pushed. Only with one change: I removed the explicit inclusion of wrappers.h in rtcan_mscan_mpc52xx.c, as it is already included thanks to rtdm_driver.h, and Jan told us that we should not do that if we want the code to be compiled for rtdm-native.
Signature · 1 line
Gilles.
Quoted 26 lines · Gilles Chanteperdrix
Quoted 25 lines · Wolfgang Grandegger
Hi Gilles
Quoted 22 lines · Gilles Chanteperdrix
Quoted 8 lines · Wolfgang Grandegger
Quoted 7 lines · Gilles Chanteperdrix
Quoted 6 lines · Wolfgang Grandegger
From: Wolfgang Grandegger <[email protected]>
This patch series adds RT-Socket-CAN support for the MSCAN on the MPC512x from Freescale by introducing a new OF platform driver for both, the MPC521x and MPC5200, while still keeping the old driver for the MPC5200 for compatibility with older kernel versions.
Quoted 7 lines
Quoted 5 lines
Hi Wolfgang,
there seems to be something missing, because I get a compilation error on lite-5200:
http://sisyphus.hd.free.fr/~gilles/bx/#powerpcWell, I obviously did not test the driver with old versions of the Linux kernel, sorry.
No problem, that is what the build test is for.
Quoted 1 line
For 2.6.29 and 2.6.30 the following patch should fix the build:
Ok. I applied a slightly different modification (fixing in
wrappers.h). I am waiting for your fix for 2.4 for pushing.
Quoted 7 lines
Quoted 2 lines
See patch below. It will contain your fixes in
wrappers.h. I will do some final testing on real hardware on monday.All green, pushed. Only with one change: I removed the explicit inclusion of
wrappers.hinrtcan_mscan_mpc52xx.c, as it is already included thanks tortdm_driver.h, and Jan told us that we should not do that if we want the code to be compiled for rtdm-native.
And it is not even needed, as I just verified.
Thanks,
Wolfgang.