Add support for powerpc (freescale p1010) -V5
Subsystems (5)
cover Add support for powerpc (freescale p1010) -V5
Marc, Wolfgang or U Bhaskar,
This patch set should have all your comments included.
I did implement a very simple clock source in the p1010rdb.c file, which, unfortunately, your tree will not have so please do not apply the last patch in the series. That will need to go to the powerpc folks and follow the p1010rdb patch from freescale.
Could you please apply the first three patches to a test branch, compile and test them on an arm based system? I would like to at least feel comfortable that I have not broken anything there.
I have tested the full set on a p1010rdb with an external PSOC based can communicator. That PSOC code has a bunch of erroneous can comms it can generate, but I do not know how the developer of that code injects those errors. As a result, no error handling from the can input has been tested. I have tested both flexcan interfaces on the board and both work with these patches in addition to the other p1010rdb patches not included.
Thanks,
Robin Holt
A message that is not in the archive (sent off-list or not yet received): 1312603504-30282-1-git-send-email-holt-sJ/[email protected]
RFC 1/4 Abstract off read/write for big/little endian.
First step in converting the flexcan driver from supporting just arm to supporting both arm and powerpc architectures.
To: Wolfgang Grandegger <[email protected]>
To: U Bhaskar-B22300 <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/net/can/flexcan.c | 140 ++++++++++++++++++++++++++------------------ 1 files changed, 83 insertions(+), 57 deletions(-)
drivers/net/can/flexcan.c +83 -57
@@ -196,6 +196,31 @@ static struct can_bittiming_const flexcan_bittiming_const = { };/* +* Abstract off the read/write for arm versus ppc. +*/ +#if defined(__BIG_ENDIAN) +static inline u32 flexcan_read (void __iomem *addr) +{ +return in_be32 (addr); +} + +static inline void flexcan_write (u32 val,void __iomem *addr) +{ +out_be32 (addr, val); +} +#else +static inline u32 flexcan_read (void __iomem *addr) +{ +return readl (addr); +} + +static inline void flexcan_write (u32 val,void __iomem *addr) +{ +writel (val, addr); +} +#endif + +/* * Swtich transceiver on or off */ static void flexcan_transceiver_switch (const struct flexcan_priv *priv,int on)
@@ -216,9 +241,9 @@ static inline void flexcan_chip_enable(struct flexcan_priv *priv)struct flexcan_regs __iomem *regs = priv->base;u32 reg; - reg =readl (®s->mcr); + reg =flexcan_read (®s->mcr); reg &= ~FLEXCAN_MCR_MDIS ; -writel (reg, ®s->mcr); +flexcan_write (reg, ®s->mcr);udelay (10 ); }
@@ -228,9 +253,9 @@ static inline void flexcan_chip_disable(struct flexcan_priv *priv)struct flexcan_regs __iomem *regs = priv->base;u32 reg; - reg =readl (®s->mcr); + reg =flexcan_read (®s->mcr); reg |=FLEXCAN_MCR_MDIS ; -writel (reg, ®s->mcr); +flexcan_write (reg, ®s->mcr); } static int flexcan_get_berr_counter(const struct net_device *dev,
@@ -238,7 +263,7 @@ static int flexcan_get_berr_counter(const struct net_device *dev, {const struct flexcan_priv *priv =netdev_priv (dev);struct flexcan_regs __iomem *regs = priv->base; -u32 reg =readl (®s->ecr); +u32 reg =flexcan_read (®s->ecr); bec->txerr = (reg >>0 ) &0xff ; bec->rxerr = (reg >>8 ) &0xff ;
@@ -272,15 +297,15 @@ static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)if (cf->can_dlc >0 ) {u32 data =be32_to_cpup ((__be32 *)&cf->data[0 ]); -writel (data, ®s->cantxfg[FLEXCAN_TX_BUF_ID ].data[0 ]); +flexcan_write (data, ®s->cantxfg[FLEXCAN_TX_BUF_ID ].data[0 ]); }if (cf->can_dlc >3 ) {u32 data =be32_to_cpup ((__be32 *)&cf->data[4 ]); -writel (data, ®s->cantxfg[FLEXCAN_TX_BUF_ID ].data[1 ]); +flexcan_write (data, ®s->cantxfg[FLEXCAN_TX_BUF_ID ].data[1 ]); } -writel (can_id, ®s->cantxfg[FLEXCAN_TX_BUF_ID ].can_id); -writel (ctrl, ®s->cantxfg[FLEXCAN_TX_BUF_ID ].can_ctrl); +flexcan_write (can_id, ®s->cantxfg[FLEXCAN_TX_BUF_ID ].can_id); +flexcan_write (ctrl, ®s->cantxfg[FLEXCAN_TX_BUF_ID ].can_ctrl);kfree_skb (skb);
@@ -468,8 +493,8 @@ static void flexcan_read_fifo(const struct net_device *dev,struct flexcan_mb __iomem *mb = ®s->cantxfg[0 ];u32 reg_ctrl, reg_id; - reg_ctrl =readl (&mb->can_ctrl); - reg_id =readl (&mb->can_id); + reg_ctrl =flexcan_read (&mb->can_ctrl); + reg_id =flexcan_read (&mb->can_id);if (reg_ctrl &FLEXCAN_MB_CNT_IDE ) cf->can_id = ((reg_id >>0 ) &CAN_EFF_MASK ) |CAN_EFF_FLAG ;else
@@ -479,12 +504,12 @@ static void flexcan_read_fifo(const struct net_device *dev, cf->can_id |=CAN_RTR_FLAG ; cf->can_dlc =get_can_dlc ((reg_ctrl >>16 ) &0xf ); - *(__be32 *)(cf->data +0 ) =cpu_to_be32 (readl (&mb->data[0 ])); - *(__be32 *)(cf->data +4 ) =cpu_to_be32 (readl (&mb->data[1 ])); + *(__be32 *)(cf->data +0 ) =cpu_to_be32 (flexcan_read (&mb->data[0 ])); + *(__be32 *)(cf->data +4 ) =cpu_to_be32 (flexcan_read (&mb->data[1 ]));/* mark as read */ -writel (FLEXCAN_IFLAG_RX_FIFO_AVAILABLE , ®s->iflag1); -readl (®s->timer); +flexcan_write (FLEXCAN_IFLAG_RX_FIFO_AVAILABLE , ®s->iflag1); +flexcan_read (®s->timer); }static int flexcan_read_frame (struct net_device *dev)
@@ -520,17 +545,17 @@ static int flexcan_poll(struct napi_struct *napi, int quota)* The error bits are cleared on read, * use saved value from irq handler. */ - reg_esr =readl (®s->esr) | priv->reg_esr; + reg_esr =flexcan_read (®s->esr) | priv->reg_esr;/* handle state changes */ work_done +=flexcan_poll_state (dev, reg_esr);/* handle RX-FIFO */ - reg_iflag1 =readl (®s->iflag1); + reg_iflag1 =flexcan_read (®s->iflag1);while (reg_iflag1 &FLEXCAN_IFLAG_RX_FIFO_AVAILABLE && work_done < quota) { work_done +=flexcan_read_frame (dev); - reg_iflag1 =readl (®s->iflag1); + reg_iflag1 =flexcan_read (®s->iflag1); }/* report bus errors */
@@ -540,8 +565,8 @@ static int flexcan_poll(struct napi_struct *napi, int quota)if (work_done < quota) {napi_complete (napi);/* enable IRQs */ -writel (FLEXCAN_IFLAG_DEFAULT , ®s->imask1); -writel (priv->reg_ctrl_default, ®s->ctrl); +flexcan_write (FLEXCAN_IFLAG_DEFAULT , ®s->imask1); +flexcan_write (priv->reg_ctrl_default, ®s->ctrl); }return work_done;
@@ -555,9 +580,9 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)struct flexcan_regs __iomem *regs = priv->base;u32 reg_iflag1, reg_esr; - reg_iflag1 =readl (®s->iflag1); - reg_esr =readl (®s->esr); -writel (FLEXCAN_ESR_ERR_INT , ®s->esr);/* ACK err IRQ */ + reg_iflag1 =flexcan_read (®s->iflag1); + reg_esr =flexcan_read (®s->esr); +flexcan_write (FLEXCAN_ESR_ERR_INT , ®s->esr);/* ACK err IRQ */ /* * schedule NAPI in case of:
@@ -573,16 +598,16 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)* save them for later use. */ priv->reg_esr = reg_esr &FLEXCAN_ESR_ERR_BUS ; -writel (FLEXCAN_IFLAG_DEFAULT & ~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE , - ®s->imask1); -writel (priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL , +flexcan_write (FLEXCAN_IFLAG_DEFAULT & + ~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE , ®s->imask1); +flexcan_write (priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL , ®s->ctrl);napi_schedule (&priv->napi); }/* FIFO overflow */ if (reg_iflag1 &FLEXCAN_IFLAG_RX_FIFO_OVERFLOW ) { -writel (FLEXCAN_IFLAG_RX_FIFO_OVERFLOW , ®s->iflag1); +flexcan_write (FLEXCAN_IFLAG_RX_FIFO_OVERFLOW , ®s->iflag1); dev->stats.rx_over_errors++; dev->stats.rx_errors++; }
@@ -591,7 +616,7 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)if (reg_iflag1 & (1 <<FLEXCAN_TX_BUF_ID )) {/* tx_bytes is incremented in flexcan_start_xmit */ stats->tx_packets++; -writel ((1 <<FLEXCAN_TX_BUF_ID ), ®s->iflag1); +flexcan_write ((1 <<FLEXCAN_TX_BUF_ID ), ®s->iflag1);netif_wake_queue (dev); }
@@ -605,7 +630,7 @@ static void flexcan_set_bittiming(struct net_device *dev)struct flexcan_regs __iomem *regs = priv->base;u32 reg; - reg =readl (®s->ctrl); + reg =flexcan_read (®s->ctrl); reg &= ~(FLEXCAN_CTRL_PRESDIV(0xff) | FLEXCAN_CTRL_RJW(0x3) | FLEXCAN_CTRL_PSEG1(0x7) |
@@ -629,11 +654,11 @@ static void flexcan_set_bittiming(struct net_device *dev) reg |=FLEXCAN_CTRL_SMP ;dev_info (dev->dev.parent,"writing ctrl=0x%08x\n" , reg); -writel (reg, ®s->ctrl); +flexcan_write (reg, ®s->ctrl);/* print chip status */ dev_dbg (dev->dev.parent,"%s: mcr=0x%08x ctrl=0x%08x\n" , __func__, -readl (®s->mcr),readl (®s->ctrl)); +flexcan_read (®s->mcr),flexcan_read (®s->ctrl)); }/*
@@ -654,10 +679,10 @@ static int flexcan_chip_start(struct net_device *dev)flexcan_chip_enable (priv);/* soft reset */ -writel (FLEXCAN_MCR_SOFTRST , ®s->mcr); +flexcan_write (FLEXCAN_MCR_SOFTRST , ®s->mcr);udelay (10 ); - reg_mcr =readl (®s->mcr); + reg_mcr =flexcan_read (®s->mcr);if (reg_mcr &FLEXCAN_MCR_SOFTRST ) { dev_err(dev->dev.parent, "Failed to softreset can module (mcr=0x%08x)\n",
@@ -679,12 +704,12 @@ static int flexcan_chip_start(struct net_device *dev)* choose format C * */ - reg_mcr =readl (®s->mcr); + reg_mcr =flexcan_read (®s->mcr); reg_mcr |=FLEXCAN_MCR_FRZ |FLEXCAN_MCR_FEN |FLEXCAN_MCR_HALT |FLEXCAN_MCR_SUPV |FLEXCAN_MCR_WRN_EN |FLEXCAN_MCR_IDAM_C ;dev_dbg (dev->dev.parent,"%s: writing mcr=0x%08x" , __func__, reg_mcr); -writel (reg_mcr, ®s->mcr); +flexcan_write (reg_mcr, ®s->mcr);/* * CTRL
@@ -702,7 +727,7 @@ static int flexcan_chip_start(struct net_device *dev)* (FLEXCAN_CTRL_ERR_MSK), too. Otherwise we don't get any * warning or bus passive interrupts. */ - reg_ctrl =readl (®s->ctrl); + reg_ctrl =flexcan_read (®s->ctrl); reg_ctrl &= ~FLEXCAN_CTRL_TSYN ; reg_ctrl |=FLEXCAN_CTRL_BOFF_REC |FLEXCAN_CTRL_LBUF |FLEXCAN_CTRL_ERR_STATE |FLEXCAN_CTRL_ERR_MSK ;
@@ -710,38 +735,39 @@ static int flexcan_chip_start(struct net_device *dev)/* save for later use */ priv->reg_ctrl_default = reg_ctrl;dev_dbg (dev->dev.parent,"%s: writing ctrl=0x%08x" , __func__, reg_ctrl); -writel (reg_ctrl, ®s->ctrl); +flexcan_write (reg_ctrl, ®s->ctrl);for (i =0 ; i <ARRAY_SIZE (regs->cantxfg); i++) { -writel (0 , ®s->cantxfg[i].can_ctrl); -writel (0 , ®s->cantxfg[i].can_id); -writel (0 , ®s->cantxfg[i].data[0 ]); -writel (0 , ®s->cantxfg[i].data[1 ]); +flexcan_write (0 , ®s->cantxfg[i].can_ctrl); +flexcan_write (0 , ®s->cantxfg[i].can_id); +flexcan_write (0 , ®s->cantxfg[i].data[0 ]); +flexcan_write (0 , ®s->cantxfg[i].data[1 ]);/* put MB into rx queue */ -writel (FLEXCAN_MB_CNT_CODE (0x4 ), ®s->cantxfg[i].can_ctrl); +flexcan_write (FLEXCAN_MB_CNT_CODE (0x4 ), + ®s->cantxfg[i].can_ctrl); }/* acceptance mask/acceptance code (accept everything) */ -writel (0x0 , ®s->rxgmask); -writel (0x0 , ®s->rx14mask); -writel (0x0 , ®s->rx15mask); +flexcan_write (0x0 , ®s->rxgmask); +flexcan_write (0x0 , ®s->rx14mask); +flexcan_write (0x0 , ®s->rx15mask);flexcan_transceiver_switch (priv,1 );/* synchronize with the can bus */ - reg_mcr =readl (®s->mcr); + reg_mcr =flexcan_read (®s->mcr); reg_mcr &= ~FLEXCAN_MCR_HALT ; -writel (reg_mcr, ®s->mcr); +flexcan_write (reg_mcr, ®s->mcr); priv->can.state =CAN_STATE_ERROR_ACTIVE ;/* enable FIFO interrupts */ -writel (FLEXCAN_IFLAG_DEFAULT , ®s->imask1); +flexcan_write (FLEXCAN_IFLAG_DEFAULT , ®s->imask1);/* print chip status */ dev_dbg (dev->dev.parent,"%s: reading mcr=0x%08x ctrl=0x%08x\n" , - __func__,readl (®s->mcr),readl (®s->ctrl)); + __func__,flexcan_read (®s->mcr),flexcan_read (®s->ctrl));return 0 ;
@@ -763,12 +789,12 @@ static void flexcan_chip_stop(struct net_device *dev)u32 reg;/* Disable all interrupts */ -writel (0 , ®s->imask1); +flexcan_write (0 , ®s->imask1);/* Disable + halt module */ - reg =readl (®s->mcr); + reg =flexcan_read (®s->mcr); reg |=FLEXCAN_MCR_MDIS |FLEXCAN_MCR_HALT ; -writel (reg, ®s->mcr); +flexcan_write (reg, ®s->mcr);flexcan_transceiver_switch (priv,0 ); priv->can.state =CAN_STATE_STOPPED ;
@@ -860,24 +886,24 @@ static int __devinit register_flexcandev(struct net_device *dev)/* select "bus clock", chip must be disabled */ flexcan_chip_disable (priv); - reg =readl (®s->ctrl); + reg =flexcan_read (®s->ctrl); reg |=FLEXCAN_CTRL_CLK_SRC ; -writel (reg, ®s->ctrl); +flexcan_write (reg, ®s->ctrl);flexcan_chip_enable (priv);/* set freeze, halt and activate FIFO, restrict register access */ - reg =readl (®s->mcr); + reg =flexcan_read (®s->mcr); reg |=FLEXCAN_MCR_FRZ |FLEXCAN_MCR_HALT |FLEXCAN_MCR_FEN |FLEXCAN_MCR_SUPV ; -writel (reg, ®s->mcr); +flexcan_write (reg, ®s->mcr);/* * Currently we only support newer versions of this core * featuring a RX FIFO. Older cores found on some Coldfire * derivates are not yet supported. */ - reg =readl (®s->mcr); + reg =flexcan_read (®s->mcr);if (!(reg &FLEXCAN_MCR_FEN )) {dev_err (dev->dev.parent,"Could not enable RX FIFO, unsupported core\n" );
Signature · 1 line
1.7.2.1
RFC 2/4 Add of_match to platform_device definition.
In reply to a message not in the archiveThe OpenFirmware devices are not matched without specifying an of_match array. Introduce that array as that is used for matching on the Freescale P1010 processor.
To: Marc Kleine-Budde <[email protected]>
To: Wolfgang Grandegger <[email protected]>
To: U Bhaskar-B22300 <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/net/can/flexcan.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-)
drivers/net/can/flexcan.c +15 -1
@@ -1033,8 +1033,22 @@ static int __devexit flexcan_remove(struct platform_device *pdev)return 0 ; } +static struct of_device_id flexcan_of_match[] = { + { + .compatible ="fsl,flexcan-v1.0" , + }, + { + .compatible ="fsl,flexcan" , + }, + {}, +}; +static struct platform_driver flexcan_driver = { - .driver.name =DRV_NAME , + .driver = { + .name =DRV_NAME , + .owner =THIS_MODULE , + .of_match_table = flexcan_of_match, + }, .probe = flexcan_probe, .remove =__devexit_p (flexcan_remove), };
Signature · 1 line
1.7.2.1
RFC 4/4 Implement a p1010rdb clock source.
In reply to a message not in the archiveflexcan driver needs the clk_get, clk_get_rate, etc functions to work. This patch provides the minimum functionality.
To: Marc Kleine-Budde <[email protected]>
To: Wolfgang Grandegger <[email protected]>
To: U Bhaskar-B22300 <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- arch/powerpc/platforms/85xx/p1010rdb.c | 78 ++++++++++++++++++++++++++++++++ 1 files changed, 78 insertions(+), 0 deletions(-)
arch/powerpc/platforms/85xx/p1010rdb.c +78 -0
@@ -28,6 +28,7 @@#include <asm/udbg.h> #include <asm/mpic.h> #include <asm/swiotlb.h> +#include <asm/clk_interface.h> #include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h>
@@ -164,6 +165,82 @@ static void __init p1010_rdb_setup_arch(void)printk (KERN_INFO "P1010 RDB board from Freescale Semiconductor\n" ); } +/* +* p1010rdb needs to provide a clock source for the flexcan driver. +*/ +struct clk { +unsigned long rate; +} p1010rdb_system_clk; + +static struct clk *p1010_rdb_clk_get (struct device *dev,const char *id) +{ +struct clk *clk; +u32 *of_property; +unsigned long clock_freq, clock_divider; +const char *dev_init_name; + +if (!dev) +return ERR_PTR (-ENOENT ); + +/* +* The can devices are named ffe1c000.can0 and ffe1d000.can1 on +* the p1010rdb. Check for the "can" portion of that name before +* returning a clock source. +*/ + dev_init_name =dev_name (dev); +if (strlen (dev_init_name) !=13 ) +return ERR_PTR (-ENOENT ); + dev_init_name +=9 ; +if (strncmp (dev_init_name,"can" ,3 )) +return ERR_PTR (-ENOENT ); + + of_property = (u32 *)of_get_property (dev->of_node,"clock_freq" ,NULL ); +if (!of_property) +return ERR_PTR (-ENOENT ); + clock_freq = *of_property; + + of_property = (u32 *)of_get_property (dev->of_node, +"fsl,flexcan-clock-divider" ,NULL ); +if (!of_property) +return ERR_PTR (-ENOENT ); + clock_divider = *of_property; + + clk =kmalloc (sizeof (struct clk ),GFP_KERNEL ); +if (!clk) +return ERR_PTR (-ENOMEM ); + + clk->rate =DIV_ROUND_CLOSEST (clock_freq / clock_divider,1000 ); + clk->rate *=1000 ; + +return clk; +} + +static void p1010_rdb_clk_put (struct clk *clk) +{ +kfree (clk); +} + +static unsigned long p1010_rdb_clk_get_rate (struct clk *clk) +{ +return clk->rate; +} + +static struct clk_interface p1010_rdb_clk_functions = { + .clk_get = p1010_rdb_clk_get, + .clk_get_rate = p1010_rdb_clk_get_rate, + .clk_put = p1010_rdb_clk_put, +}; + +static void __init p1010_rdb_clk_init (void ) +{ + clk_functions = p1010_rdb_clk_functions; +} + +static void __init p1010_rdb_init (void ) +{ +p1010_rdb_clk_init (); +} +static struct of_device_id __initdata p1010rdb_ids[] = { { .type ="soc" , }, { .compatible ="soc" , },
@@ -195,6 +272,7 @@ define_machine(p1010_rdb) { .name = "P1010 RDB", .probe = p1010_rdb_probe, .setup_arch = p1010_rdb_setup_arch, + .init = p1010_rdb_init, .init_IRQ = p1010_rdb_pic_init, #ifdef CONFIG_PCI .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
Signature · 1 line
1.7.2.1
A message that is not in the archive (sent off-list or not yet received): 1312603504-30282-5-git-send-email-holt-sJ/[email protected]
Re: [RFC 4/4] [powerpc] Implement a p1010rdb clock source.
Quoted 2 lines · Robin Holt
flexcan driver needs the
clk_get,clk_get_rate, etc functions to work. This patch provides the minimum functionality.
This patch has to go via the powerpc git tree. Added linuxppc-dev-uLR06cmDAlY/[email protected] on CC.
Quoted 106 lines
Signed-off-by Robin Holt <holt-sJ/[email protected]>To: Marc Kleine-Budde <[email protected]>
To: Wolfgang Grandegger <[email protected]>
To: U Bhaskar-B22300 <[email protected]>
Cc: [email protected]
Cc: [email protected]--- arch/powerpc/platforms/85xx/p1010rdb.c | 78 ++++++++++++++++++++++++++++++++ 1 files changed, 78 insertions(+), 0 deletions(-)arch/powerpc/platforms/85xx/p1010rdb.c +77
-0@@ -28,6 +28,7 @@#include <asm/udbg.h> #include <asm/mpic.h> #include <asm/swiotlb.h> +#include <asm/clk_interface.h> #include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h> @@ -164,6 +165,82 @@ static void __init p1010_rdb_setup_arch(void)printk (KERN_INFO "P1010 RDB board from Freescale Semiconductor\n" ); } +/* +* p1010rdb needs to provide a clock source for the flexcan driver. +*/ +struct clk { +unsigned long rate; +} p1010rdb_system_clk; + +static struct clk *p1010_rdb_clk_get (struct device *dev,const char *id) +{ +struct clk *clk; +u32 *of_property; +unsigned long clock_freq, clock_divider; +const char *dev_init_name; + +if (!dev) +return ERR_PTR (-ENOENT ); + +/* +* The can devices are named ffe1c000.can0 and ffe1d000.can1 on +* the p1010rdb. Check for the "can" portion of that name before +* returning a clock source. +*/ + dev_init_name =dev_name (dev); +if (strlen (dev_init_name) !=13 ) +return ERR_PTR (-ENOENT ); + dev_init_name +=9 ; +if (strncmp (dev_init_name,"can" ,3 )) +return ERR_PTR (-ENOENT ); + + of_property = (u32 *)of_get_property (dev->of_node,"clock_freq" ,NULL ); +if (!of_property) +return ERR_PTR (-ENOENT ); + clock_freq = *of_property; + + of_property = (u32 *)of_get_property (dev->of_node, +"fsl,flexcan-clock-divider" ,NULL ); +if (!of_property) +return ERR_PTR (-ENOENT ); + clock_divider = *of_property; + + clk =kmalloc (sizeof (struct clk ),GFP_KERNEL ); +if (!clk) +return ERR_PTR (-ENOMEM ); + + clk->rate =DIV_ROUND_CLOSEST (clock_freq / clock_divider,1000 ); + clk->rate *=1000 ; + +return clk; +} + +static void p1010_rdb_clk_put (struct clk *clk) +{ +kfree (clk); +} + +static unsigned long p1010_rdb_clk_get_rate (struct clk *clk) +{ +return clk->rate; +} + +static struct clk_interface p1010_rdb_clk_functions = { + .clk_get = p1010_rdb_clk_get, + .clk_get_rate = p1010_rdb_clk_get_rate, + .clk_put = p1010_rdb_clk_put, +}; + +static void __init p1010_rdb_clk_init (void ) +{ + clk_functions = p1010_rdb_clk_functions; +} + +static void __init p1010_rdb_init (void ) +{ +p1010_rdb_clk_init (); +} +static struct of_device_id __initdata p1010rdb_ids[] = { { .type ="soc" , }, { .compatible ="soc" , },
arch/powerpc/platforms/85xx/p1010rdb.c define_machine(p1010_rdb) { · line 278
Quoted 7 lines
arch/powerpc/platforms/85xx/p1010rdb.c +1
-0@@ -195,6 +272,7 @@ define_machine(p1010_rdb) { .name = "P1010 RDB", .probe = p1010_rdb_probe, .setup_arch = p1010_rdb_setup_arch, + .init = p1010_rdb_init, .init_IRQ = p1010_rdb_pic_init, #ifdef CONFIG_PCI .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
_______________________________________________
Socketcan-core mailing list [email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core
Kumar Gala
NAKRe: [RFC 4/4] [powerpc] Implement a p1010rdb clock source.
Quoted 15 lines · Marc Kleine-Budde
Quoted 2 lines · Robin Holt
flexcan driver needs the
clk_get,clk_get_rate, etc functions to work. This patch provides the minimum functionality.=20
This patch has to go via the powerpc git tree. Added [email protected] on CC.
=20Quoted 8 lines
Signed-off-by Robin Holt <[email protected]>To: Marc Kleine-Budde <[email protected]>
To: Wolfgang Grandegger <[email protected]>
To: U Bhaskar-B22300 <[email protected]>
Cc: [email protected]
Cc: [email protected]
---arch/powerpc/platforms/85xx/p1010rdb.c| 78 =
++++++++++++++++++++++++++++++++
Quoted 1 line
Quoted 1 line
1 files changed, 78 insertions(+), 0 deletions(-)
NAK.
This doesn't look right at all. We should be doing something based on = the device tree node that isn't board specific.
I believe Bhaskar has a version of flexcan support that he's been = working on cleanup up for upstream.
- k=
A message that is not in the archive (sent off-list or not yet received): 39414D86-7822-4B92-B005-351890A2A167-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org
Re: [RFC 4/4] [powerpc] Implement a p1010rdb clock source.
Quoted 20 lines · Kumar Gala
Quoted 16 lines · Marc Kleine-Budde
Quoted 2 lines · Robin Holt
flexcan driver needs the
clk_get,clk_get_rate, etc functions to work. This patch provides the minimum functionality.This patch has to go via the powerpc git tree. Added linuxppc-dev-uLR06cmDAlY/[email protected] on CC.
Quoted 9 lines
Signed-off-by Robin Holt <holt-sJ/[email protected]>To: Marc Kleine-Budde <[email protected]>
To: Wolfgang Grandegger <[email protected]>
To: U Bhaskar-B22300 <[email protected]>
Cc: [email protected]
Cc: [email protected]
---arch/powerpc/platforms/85xx/p1010rdb.c| 78 ++++++++++++++++++++++++++++++++1 files changed, 78 insertions(+), 0 deletions(-)
Quoted 5 lines
NAK.
This doesn't look right at all. We should be doing something based on the device tree node that isn't board specific.
I believe Bhaskar has a version of flexcan support that he's been working on cleanup up for upstream.
That version may be similar to what is in the freescale BSP which puts the clock functions inside flexcan.c
The powerpc arch already provides a means for individual boards to provide the clock functions. I am not posting this patch here for acceptance for powerpc and I am sure I will get feedback there when I post to their mailing list. I am posting it here only to show that the flexcan developers earlier assertion that this can and should be done in the arch tree is correct and will work for the p1010 assuming we can get changes into the arch/powerpc directory to implement these clk_* functions.
Thanks,
Robin
Re: [RFC 4/4] [powerpc] Implement a p1010rdb clock source.
Quoted 30 lines · Robin Holt
Quoted 20 lines · Kumar Gala
Quoted 16 lines · Marc Kleine-Budde
Quoted 2 lines · Robin Holt
flexcan driver needs the
clk_get,clk_get_rate, etc functions to work. This patch provides the minimum functionality.This patch has to go via the powerpc git tree. Added [email protected] on CC.
Quoted 9 lines
Signed-off-by Robin Holt <[email protected]>To: Marc Kleine-Budde <[email protected]>
To: Wolfgang Grandegger <[email protected]>
To: U Bhaskar-B22300 <[email protected]>
Cc: [email protected]
Cc: [email protected]
---arch/powerpc/platforms/85xx/p1010rdb.c| 78 ++++++++++++++++++++++++++++++++1 files changed, 78 insertions(+), 0 deletions(-)Quoted 5 lines
NAK.
This doesn't look right at all. We should be doing something based on the device tree node that isn't board specific.
I believe Bhaskar has a version of flexcan support that he's been working on cleanup up for upstream.
That version may be similar to what is in the freescale BSP which puts the clock functions inside
flexcan.c
Quoted 7 lines
The powerpc arch already provides a means for individual boards to provide the clock functions. I am not posting this patch here for acceptance for powerpc and I am sure I will get feedback there when I post to their mailing list. I am posting it here only to show that the flexcan developers earlier assertion that this can and should be done in the arch tree is correct and will work for the p1010 assuming we can get changes into the
arch/powerpcdirectory to implement these clk_* functions.
My point is that I don't think they should live in the arch code. The clk_* functions you want to implement are tied more the FlexCAN IP than anything arch specific. As such I believe they should be in the driver.
For example when FSL has a P9999 with FlexCAN on it, we should NOT have to add any arch code to support it.
- k
A message that is not in the archive (sent off-list or not yet received): 3C4B6145-5C75-4A3C-B504-DA32E0D2EC8A-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org
Re: [RFC 4/4] [powerpc] Implement a p1010rdb clock source.
Quoted 41 lines · Kumar Gala
Quoted 30 lines · Robin Holt
Quoted 20 lines · Kumar Gala
Quoted 16 lines · Marc Kleine-Budde
Quoted 2 lines · Robin Holt
flexcan driver needs the
clk_get,clk_get_rate, etc functions to work. This patch provides the minimum functionality.This patch has to go via the powerpc git tree. Added linuxppc-dev-uLR06cmDAlY/[email protected] on CC.
Quoted 9 lines
Signed-off-by Robin Holt <holt-sJ/[email protected]>To: Marc Kleine-Budde <[email protected]>
To: Wolfgang Grandegger <[email protected]>
To: U Bhaskar-B22300 <[email protected]>
Cc: [email protected]
Cc: [email protected]
---arch/powerpc/platforms/85xx/p1010rdb.c| 78 ++++++++++++++++++++++++++++++++1 files changed, 78 insertions(+), 0 deletions(-)Quoted 5 lines
NAK.
This doesn't look right at all. We should be doing something based on the device tree node that isn't board specific.
I believe Bhaskar has a version of flexcan support that he's been working on cleanup up for upstream.
That version may be similar to what is in the freescale BSP which puts the clock functions inside
flexcan.cQuoted 7 lines
The powerpc arch already provides a means for individual boards to provide the clock functions. I am not posting this patch here for acceptance for powerpc and I am sure I will get feedback there when I post to their mailing list. I am posting it here only to show that the flexcan developers earlier assertion that this can and should be done in the arch tree is correct and will work for the p1010 assuming we can get changes into the
arch/powerpcdirectory to implement these clk_* functions.
Quoted 3 lines
My point is that I don't think they should live in the arch code. The clk_* functions you want to implement are tied more the FlexCAN IP than anything arch specific. As such I believe they should be in the driver.
For example when FSL has a P9999 with FlexCAN on it, we should NOT have to add any arch code to support it.
The Flexcan is found on ARM and now also on PowerPC SOCs. My current understanding is that the ability to set the clock source and divider is only available on PowerPC SOCs and therefore it's clearly arch specific and should go to arch/powerpc/sysdev/fsl_soc.c if it's common for all PowerPC platforms. What do you think?
Wolfgang.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [RFC 4/4] [powerpc] Implement a p1010rdb clock source.
Quoted 44 lines · Wolfgang Grandegger
Quoted 43 lines · Kumar Gala
Quoted 30 lines · Robin Holt
Quoted 20 lines · Kumar Gala
Quoted 16 lines · Marc Kleine-Budde
Quoted 2 lines · Robin Holt
flexcan driver needs the
clk_get,clk_get_rate, etc functions to work. This patch provides the minimum functionality.This patch has to go via the powerpc git tree. Added linuxppc-dev-uLR06cmDAlY/[email protected] on CC.
Quoted 9 lines
Signed-off-by Robin Holt <holt-sJ/[email protected]>To: Marc Kleine-Budde <[email protected]>
To: Wolfgang Grandegger <[email protected]>
To: U Bhaskar-B22300 <[email protected]>
Cc: [email protected]
Cc: [email protected]
---arch/powerpc/platforms/85xx/p1010rdb.c| 78 ++++++++++++++++++++++++++++++++1 files changed, 78 insertions(+), 0 deletions(-)Quoted 5 lines
NAK.
This doesn't look right at all. We should be doing something based on the device tree node that isn't board specific.
I believe Bhaskar has a version of flexcan support that he's been working on cleanup up for upstream.
That version may be similar to what is in the freescale BSP which puts the clock functions inside
flexcan.cQuoted 7 lines
The powerpc arch already provides a means for individual boards to provide the clock functions. I am not posting this patch here for acceptance for powerpc and I am sure I will get feedback there when I post to their mailing list. I am posting it here only to show that the flexcan developers earlier assertion that this can and should be done in the arch tree is correct and will work for the p1010 assuming we can get changes into the
arch/powerpcdirectory to implement these clk_* functions.My point is that I don't think they should live in the arch code. The clk_* functions you want to implement are tied more the FlexCAN IP than anything arch specific. As such I believe they should be in the driver.
Quoted 7 lines
Quoted 1 line
For example when FSL has a P9999 with FlexCAN on it, we should NOT have to add any arch code to support it.
The Flexcan is found on ARM and now also on PowerPC SOCs. My current understanding is that the ability to set the clock source and divider is only available on PowerPC SOCs and therefore it's clearly arch specific and should go to
arch/powerpc/sysdev/fsl_soc.cif it's common for all PowerPC platforms. What do you think?
There is a bit in the CAN-Controller that selects the clock (at least on arm). The current driver just supports the bus clock. Support for the other, the oscillator clock, has not been implemented so far.
IIRC the oscillator clock has a frequency that results in worse standard timing than the bus clock.
cheers, Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
_______________________________________________
Socketcan-core mailing list [email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core
Quoted 13 lines · Robin Holt
Marc, Wolfgang or U Bhaskar,
This patch set should have all your comments included.
I did implement a very simple clock source in the
p1010rdb.cfile, which, unfortunately, your tree will not have so please do not apply the last patch in the series. That will need to go to the powerpc folks and follow the p1010rdb patch from freescale.Could you please apply the first three patches to a test branch, compile and test them on an arm based system? I would like to at least feel comfortable that I have not broken anything there.
Quoted 6 lines
I have tested the full set on a p1010rdb with an external PSOC based can communicator. That PSOC code has a bunch of erroneous can comms it can generate, but I do not know how the developer of that code injects those errors. As a result, no error handling from the can input has been tested. I have tested both flexcan interfaces on the board and both work with these patches in addition to the other p1010rdb patches not included.
ARGH!
I just did a quick look back at my git log, and I have one other patch earlier in the series where I committed a one-line change to flexcan.c which is probably very relevant to you, but not so much to me. I removed the mach/clock.h which does not seem to exist for powerpc.
Can any of you tell me if that is relevant for the arm flexcan build? If not, does it seem reasonable to just remove it early on?
Thanks,
Robin
A message that is not in the archive (sent off-list or not yet received): 20110806110602.GO4926-sJ/[email protected]
Quoted 23 lines · Robin Holt
Quoted 13 lines · Robin Holt
Marc, Wolfgang or U Bhaskar,
This patch set should have all your comments included.
I did implement a very simple clock source in the
p1010rdb.cfile, which, unfortunately, your tree will not have so please do not apply the last patch in the series. That will need to go to the powerpc folks and follow the p1010rdb patch from freescale.Could you please apply the first three patches to a test branch, compile and test them on an arm based system? I would like to at least feel comfortable that I have not broken anything there.
Quoted 6 lines
I have tested the full set on a p1010rdb with an external PSOC based can communicator. That PSOC code has a bunch of erroneous can comms it can generate, but I do not know how the developer of that code injects those errors. As a result, no error handling from the can input has been tested. I have tested both flexcan interfaces on the board and both work with these patches in addition to the other p1010rdb patches not included.
ARGH!
Quoted 7 lines
I just did a quick look back at my git log, and I have one other patch earlier in the series where I committed a one-line change to
flexcan.cwhich is probably very relevant to you, but not so much to me. I removed themach/clock.hwhich does not seem to exist for powerpc.Can any of you tell me if that is relevant for the arm flexcan build? If not, does it seem reasonable to just remove it early on?
It looks like the more-nearly right thing to do is to #include <linux/clkdev.h> but powerpc does not implement one.
Thanks,
Robin
RFC 3/4 Add support for FLEXCAN_DEBUG
In reply to Robin HoltAdd a wrapper function for a register dump when a developer defines FLEXCAN_DEBUG.
To: Marc Kleine-Budde <[email protected]>
To: Wolfgang Grandegger <[email protected]>
To: U Bhaskar-B22300 <[email protected]>
Cc: [email protected]
Cc: [email protected]
--- drivers/net/can/flexcan.c | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-)
drivers/net/can/flexcan.c +37 -0
@@ -220,6 +220,35 @@ static inline void flexcan_write(u32 val, void __iomem *addr) }#endif +#if defined(FLEXCAN_DEBUG ) +void _flexcan_reg_dump (struct net_device *dev,const char *file,int line, +const char *func) +{ +const struct flexcan_priv *priv =netdev_priv (dev); +struct flexcan_regs __iomem *regs = priv->base; + +netdev_info ("flexcan_reg_dump:%s:%d:%s()\n" , file, line, func); +netdev_info ("\t mcr 0x%08x ctrl 0x%08x timer 0x%08x rxg 0x%08x" , +flexcan_read (®s->mcr), +flexcan_read (®s->ctrl), +flexcan_read (®s->timer), +flexcan_read (®s->rxgmask)); +netdev_info ("\t rx14 0x%08x rx15 0x%08x ecr 0x%08x esr 0x%08x" , +flexcan_read (®s->rx14mask), +flexcan_read (®s->rx15mask), +flexcan_read (®s->ecr), +flexcan_read (®s->esr)); +netdev_info ("\timsk2 0x%08x imsk1 0x%08x iflg2 0x%08x iflg1 0x%08x" , +flexcan_read (®s->imask2), +flexcan_read (®s->imask1), +flexcan_read (®s->iflag2), +flexcan_read (®s->iflag1)); +} +#define flexcan_reg_dump (_d) _flexcan_reg_dump(_d, __FILE__, __LINE__, __func__) +#else +#define flexcan_reg_dump (_d) +#endif +/* * Swtich transceiver on or off */
@@ -280,6 +309,8 @@ static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)u32 can_id;u32 ctrl =FLEXCAN_MB_CNT_CODE (0xc ) | (cf->can_dlc <<16 ); +flexcan_reg_dump (dev); +if (can_dropped_invalid_skb (dev, skb))return NETDEV_TX_OK ;
@@ -312,6 +343,8 @@ static int flexcan_start_xmit(struct sk_buff *skb, struct net_device *dev)/* tx_packets is incremented in flexcan_irq */ stats->tx_bytes += cf->can_dlc; +flexcan_reg_dump (dev); +return NETDEV_TX_OK ; }
@@ -580,6 +613,8 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)struct flexcan_regs __iomem *regs = priv->base;u32 reg_iflag1, reg_esr; +flexcan_reg_dump (dev); + reg_iflag1 =flexcan_read (®s->iflag1); reg_esr =flexcan_read (®s->esr);flexcan_write (FLEXCAN_ESR_ERR_INT , ®s->esr);/* ACK err IRQ */
@@ -620,6 +655,8 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)netif_wake_queue (dev); } +flexcan_reg_dump (dev); +return IRQ_HANDLED ; }
Signature · 1 line
1.7.2.1