[PATCH v11 0/5] flexcan/powerpc: Add support for powerpc flexcan (freescale p1010)

STALE5502d

12 messages, 3 authors, 2011-08-11 · open the first message on its own page

[PATCH v11 0/5] flexcan/powerpc: Add support for powerpc flexcan (freescale p1010)

From: Robin Holt <hidden>
Date: 2011-08-10 16:28:15

With all the patches applied, my p1010rdb works for communicating between
its two can ports and also can communicate with an external PSOC.  I have
done no testing beyond compile testing on an arm system as I have no
access to an arm based system.

For the first three patches in the series, I believe they are all ready
for forwarding to David S. Miller for the netdev tree.  I think patch
4 is ready for submission to the PPC85xx maintainer.  Patch 5 changed
from the previous post by adding a second compatible string for the
fsl,flexcan-p1010 and bringing back the Documentation file in a more
correct form.

Thanks,
Robin Holt

[PATCH v11 1/5] flexcan: Remove #include <mach/clock.h>

From: Robin Holt <hidden>
Date: 2011-08-10 16:28:30

powerpc does not have a mach-####/clock.h.  When testing, I found neither
arm nor powerpc needed the mach/clock.h at all so I removed it.

Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Wolfgang Grandegger <redacted>
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de
Cc: netdev@vger.kernel.org
Cc: PPC list <redacted>
---
 drivers/net/can/flexcan.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 1767811..586b2cd 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -35,8 +35,6 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 
-#include <mach/clock.h>
-
 #define DRV_NAME			"flexcan"
 
 /* 8 for RX fifo and 2 error handling */
-- 
1.7.2.1

[PATCH v11 2/5] flexcan: Abstract off read/write for big/little endian.

From: Robin Holt <hidden>
Date: 2011-08-10 16:28:32

Make flexcan driver handle register reads in the appropriate endianess.
This was a basic search and replace and then define some inlines.

Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Wolfgang Grandegger <redacted>
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de
Cc: netdev@vger.kernel.org
Cc: PPC list <redacted>
---
 drivers/net/can/flexcan.c |  140 ++++++++++++++++++++++++++------------------
 1 files changed, 83 insertions(+), 57 deletions(-)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 586b2cd..68cbe52 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -190,6 +190,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)
@@ -210,9 +235,9 @@ static inline void flexcan_chip_enable(struct flexcan_priv *priv)
 	struct flexcan_regs __iomem *regs = priv->base;
 	u32 reg;
 
-	reg = readl(&regs->mcr);
+	reg = flexcan_read(&regs->mcr);
 	reg &= ~FLEXCAN_MCR_MDIS;
-	writel(reg, &regs->mcr);
+	flexcan_write(reg, &regs->mcr);
 
 	udelay(10);
 }
@@ -222,9 +247,9 @@ static inline void flexcan_chip_disable(struct flexcan_priv *priv)
 	struct flexcan_regs __iomem *regs = priv->base;
 	u32 reg;
 
-	reg = readl(&regs->mcr);
+	reg = flexcan_read(&regs->mcr);
 	reg |= FLEXCAN_MCR_MDIS;
-	writel(reg, &regs->mcr);
+	flexcan_write(reg, &regs->mcr);
 }
 
 static int flexcan_get_berr_counter(const struct net_device *dev,
@@ -232,7 +257,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(&regs->ecr);
+	u32 reg = flexcan_read(&regs->ecr);
 
 	bec->txerr = (reg >> 0) & 0xff;
 	bec->rxerr = (reg >> 8) & 0xff;
@@ -266,15 +291,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, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[0]);
+		flexcan_write(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[0]);
 	}
 	if (cf->can_dlc > 3) {
 		u32 data = be32_to_cpup((__be32 *)&cf->data[4]);
-		writel(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
+		flexcan_write(data, &regs->cantxfg[FLEXCAN_TX_BUF_ID].data[1]);
 	}
 
-	writel(can_id, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
-	writel(ctrl, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
+	flexcan_write(can_id, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_id);
+	flexcan_write(ctrl, &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
 
 	kfree_skb(skb);
 
@@ -462,8 +487,8 @@ static void flexcan_read_fifo(const struct net_device *dev,
 	struct flexcan_mb __iomem *mb = &regs->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
@@ -473,12 +498,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, &regs->iflag1);
-	readl(&regs->timer);
+	flexcan_write(FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, &regs->iflag1);
+	flexcan_read(&regs->timer);
 }
 
 static int flexcan_read_frame(struct net_device *dev)
@@ -514,17 +539,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(&regs->esr) | priv->reg_esr;
+	reg_esr = flexcan_read(&regs->esr) | priv->reg_esr;
 
 	/* handle state changes */
 	work_done += flexcan_poll_state(dev, reg_esr);
 
 	/* handle RX-FIFO */
-	reg_iflag1 = readl(&regs->iflag1);
+	reg_iflag1 = flexcan_read(&regs->iflag1);
 	while (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE &&
 	       work_done < quota) {
 		work_done += flexcan_read_frame(dev);
-		reg_iflag1 = readl(&regs->iflag1);
+		reg_iflag1 = flexcan_read(&regs->iflag1);
 	}
 
 	/* report bus errors */
@@ -534,8 +559,8 @@ static int flexcan_poll(struct napi_struct *napi, int quota)
 	if (work_done < quota) {
 		napi_complete(napi);
 		/* enable IRQs */
-		writel(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
-		writel(priv->reg_ctrl_default, &regs->ctrl);
+		flexcan_write(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
+		flexcan_write(priv->reg_ctrl_default, &regs->ctrl);
 	}
 
 	return work_done;
@@ -549,9 +574,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(&regs->iflag1);
-	reg_esr = readl(&regs->esr);
-	writel(FLEXCAN_ESR_ERR_INT, &regs->esr);	/* ACK err IRQ */
+	reg_iflag1 = flexcan_read(&regs->iflag1);
+	reg_esr = flexcan_read(&regs->esr);
+	flexcan_write(FLEXCAN_ESR_ERR_INT, &regs->esr);	/* ACK err IRQ */
 
 	/*
 	 * schedule NAPI in case of:
@@ -567,16 +592,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,
-		       &regs->imask1);
-		writel(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
+		flexcan_write(FLEXCAN_IFLAG_DEFAULT &
+			~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, &regs->imask1);
+		flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
 		       &regs->ctrl);
 		napi_schedule(&priv->napi);
 	}
 
 	/* FIFO overflow */
 	if (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_OVERFLOW) {
-		writel(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW, &regs->iflag1);
+		flexcan_write(FLEXCAN_IFLAG_RX_FIFO_OVERFLOW, &regs->iflag1);
 		dev->stats.rx_over_errors++;
 		dev->stats.rx_errors++;
 	}
@@ -585,7 +610,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), &regs->iflag1);
+		flexcan_write((1 << FLEXCAN_TX_BUF_ID), &regs->iflag1);
 		netif_wake_queue(dev);
 	}
 
@@ -599,7 +624,7 @@ static void flexcan_set_bittiming(struct net_device *dev)
 	struct flexcan_regs __iomem *regs = priv->base;
 	u32 reg;
 
-	reg = readl(&regs->ctrl);
+	reg = flexcan_read(&regs->ctrl);
 	reg &= ~(FLEXCAN_CTRL_PRESDIV(0xff) |
 		 FLEXCAN_CTRL_RJW(0x3) |
 		 FLEXCAN_CTRL_PSEG1(0x7) |
@@ -623,11 +648,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, &regs->ctrl);
+	flexcan_write(reg, &regs->ctrl);
 
 	/* print chip status */
 	dev_dbg(dev->dev.parent, "%s: mcr=0x%08x ctrl=0x%08x\n", __func__,
-		readl(&regs->mcr), readl(&regs->ctrl));
+		flexcan_read(&regs->mcr), flexcan_read(&regs->ctrl));
 }
 
 /*
@@ -648,10 +673,10 @@ static int flexcan_chip_start(struct net_device *dev)
 	flexcan_chip_enable(priv);
 
 	/* soft reset */
-	writel(FLEXCAN_MCR_SOFTRST, &regs->mcr);
+	flexcan_write(FLEXCAN_MCR_SOFTRST, &regs->mcr);
 	udelay(10);
 
-	reg_mcr = readl(&regs->mcr);
+	reg_mcr = flexcan_read(&regs->mcr);
 	if (reg_mcr & FLEXCAN_MCR_SOFTRST) {
 		dev_err(dev->dev.parent,
 			"Failed to softreset can module (mcr=0x%08x)\n",
@@ -673,12 +698,12 @@ static int flexcan_chip_start(struct net_device *dev)
 	 * choose format C
 	 *
 	 */
-	reg_mcr = readl(&regs->mcr);
+	reg_mcr = flexcan_read(&regs->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, &regs->mcr);
+	flexcan_write(reg_mcr, &regs->mcr);
 
 	/*
 	 * CTRL
@@ -696,7 +721,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(&regs->ctrl);
+	reg_ctrl = flexcan_read(&regs->ctrl);
 	reg_ctrl &= ~FLEXCAN_CTRL_TSYN;
 	reg_ctrl |= FLEXCAN_CTRL_BOFF_REC | FLEXCAN_CTRL_LBUF |
 		FLEXCAN_CTRL_ERR_STATE | FLEXCAN_CTRL_ERR_MSK;
@@ -704,38 +729,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, &regs->ctrl);
+	flexcan_write(reg_ctrl, &regs->ctrl);
 
 	for (i = 0; i < ARRAY_SIZE(regs->cantxfg); i++) {
-		writel(0, &regs->cantxfg[i].can_ctrl);
-		writel(0, &regs->cantxfg[i].can_id);
-		writel(0, &regs->cantxfg[i].data[0]);
-		writel(0, &regs->cantxfg[i].data[1]);
+		flexcan_write(0, &regs->cantxfg[i].can_ctrl);
+		flexcan_write(0, &regs->cantxfg[i].can_id);
+		flexcan_write(0, &regs->cantxfg[i].data[0]);
+		flexcan_write(0, &regs->cantxfg[i].data[1]);
 
 		/* put MB into rx queue */
-		writel(FLEXCAN_MB_CNT_CODE(0x4), &regs->cantxfg[i].can_ctrl);
+		flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
+			&regs->cantxfg[i].can_ctrl);
 	}
 
 	/* acceptance mask/acceptance code (accept everything) */
-	writel(0x0, &regs->rxgmask);
-	writel(0x0, &regs->rx14mask);
-	writel(0x0, &regs->rx15mask);
+	flexcan_write(0x0, &regs->rxgmask);
+	flexcan_write(0x0, &regs->rx14mask);
+	flexcan_write(0x0, &regs->rx15mask);
 
 	flexcan_transceiver_switch(priv, 1);
 
 	/* synchronize with the can bus */
-	reg_mcr = readl(&regs->mcr);
+	reg_mcr = flexcan_read(&regs->mcr);
 	reg_mcr &= ~FLEXCAN_MCR_HALT;
-	writel(reg_mcr, &regs->mcr);
+	flexcan_write(reg_mcr, &regs->mcr);
 
 	priv->can.state = CAN_STATE_ERROR_ACTIVE;
 
 	/* enable FIFO interrupts */
-	writel(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
+	flexcan_write(FLEXCAN_IFLAG_DEFAULT, &regs->imask1);
 
 	/* print chip status */
 	dev_dbg(dev->dev.parent, "%s: reading mcr=0x%08x ctrl=0x%08x\n",
-		__func__, readl(&regs->mcr), readl(&regs->ctrl));
+		__func__, flexcan_read(&regs->mcr), flexcan_read(&regs->ctrl));
 
 	return 0;
 
@@ -757,12 +783,12 @@ static void flexcan_chip_stop(struct net_device *dev)
 	u32 reg;
 
 	/* Disable all interrupts */
-	writel(0, &regs->imask1);
+	flexcan_write(0, &regs->imask1);
 
 	/* Disable + halt module */
-	reg = readl(&regs->mcr);
+	reg = flexcan_read(&regs->mcr);
 	reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
-	writel(reg, &regs->mcr);
+	flexcan_write(reg, &regs->mcr);
 
 	flexcan_transceiver_switch(priv, 0);
 	priv->can.state = CAN_STATE_STOPPED;
@@ -854,24 +880,24 @@ static int __devinit register_flexcandev(struct net_device *dev)
 
 	/* select "bus clock", chip must be disabled */
 	flexcan_chip_disable(priv);
-	reg = readl(&regs->ctrl);
+	reg = flexcan_read(&regs->ctrl);
 	reg |= FLEXCAN_CTRL_CLK_SRC;
-	writel(reg, &regs->ctrl);
+	flexcan_write(reg, &regs->ctrl);
 
 	flexcan_chip_enable(priv);
 
 	/* set freeze, halt and activate FIFO, restrict register access */
-	reg = readl(&regs->mcr);
+	reg = flexcan_read(&regs->mcr);
 	reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT |
 		FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV;
-	writel(reg, &regs->mcr);
+	flexcan_write(reg, &regs->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(&regs->mcr);
+	reg = flexcan_read(&regs->mcr);
 	if (!(reg & FLEXCAN_MCR_FEN)) {
 		dev_err(dev->dev.parent,
 			"Could not enable RX FIFO, unsupported core\n");
-- 
1.7.2.1

[PATCH v11 4/5] powerpc: Add flexcan device support for p1010rdb.

From: Robin Holt <hidden>
Date: 2011-08-10 16:28:46

I added a simple clock source for the p1010rdb so the flexcan driver
could determine a clock frequency.  The p1010 flexcan device only has
an oscillator of system bus frequency divided by 2.

Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>,
Acked-by: Wolfgang Grandegger <redacted>,
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de,
Cc: netdev@vger.kernel.org,
Cc: PPC list <redacted>
Cc: Kumar Gala <redacted>
---
 arch/powerpc/platforms/85xx/Kconfig    |    2 +
 arch/powerpc/platforms/85xx/Makefile   |    2 +
 arch/powerpc/platforms/85xx/clock.c    |   52 ++++++++++++++++++++++++++++++++
 arch/powerpc/platforms/85xx/p1010rdb.c |    8 +++++
 4 files changed, 64 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/platforms/85xx/clock.c
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index 498534c..c4304ae 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -70,6 +70,8 @@ config MPC85xx_RDB
 config P1010_RDB
 	bool "Freescale P1010RDB"
 	select DEFAULT_UIMAGE
+	select HAVE_CAN_FLEXCAN if NET && CAN
+	select PPC_CLOCK if CAN_FLEXCAN
 	help
 	  This option enables support for the MPC85xx RDB (P1010 RDB) board
 
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index a971b32..cc7f381 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -3,6 +3,8 @@
 #
 obj-$(CONFIG_SMP) += smp.o
 
+obj-$(CONFIG_PPC_CLOCK)   += clock.o
+
 obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
 obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
 obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
diff --git a/arch/powerpc/platforms/85xx/clock.c b/arch/powerpc/platforms/85xx/clock.c
new file mode 100644
index 0000000..0b6db1d
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/clock.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011 SGI, inc.
+ *
+ * This code is licensed for use under the GPL V2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/of.h>
+
+#include <asm/clk_interface.h>
+
+#include <sysdev/fsl_soc.h>
+
+/*
+ * p1010 needs to provide a clock source for the flexcan driver. The
+ * oscillator for the p1010 processor is only ever the system clock / 2.
+ */
+
+static struct clk *mpc85xx_clk_get(struct device *dev, const char *id)
+{
+	if (!dev)
+		return ERR_PTR(-ENOENT);
+
+	if (!dev->of_node ||
+	    !of_device_is_compatible(dev->of_node, "fsl,flexcan"))
+		return ERR_PTR(-ENOENT);
+
+	return NULL;
+}
+
+static void mpc85xx_clk_put(struct clk *clk)
+{
+	return;
+}
+
+static unsigned long mpc85xx_clk_get_rate(struct clk *clk)
+{
+	return fsl_get_sys_freq() / 2;
+}
+
+static struct clk_interface mpc85xx_clk_functions = {
+	.clk_get = mpc85xx_clk_get,
+	.clk_get_rate = mpc85xx_clk_get_rate,
+	.clk_put = mpc85xx_clk_put,
+};
+
+void __init mpc85xx_clk_init(void)
+{
+	clk_functions = mpc85xx_clk_functions;
+}
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index d7387fa..5e52122 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -81,6 +81,13 @@ static void __init p1010_rdb_setup_arch(void)
 	printk(KERN_INFO "P1010 RDB board from Freescale Semiconductor\n");
 }
 
+extern void mpc85xx_clk_init(void);
+
+static void __init p1010_rdb_init(void)
+{
+	mpc85xx_clk_init();
+}
+
 static struct of_device_id __initdata p1010rdb_ids[] = {
 	{ .type = "soc", },
 	{ .compatible = "soc", },
@@ -111,6 +118,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,
-- 
1.7.2.1

Re: [PATCH v11 4/5] powerpc: Add flexcan device support for p1010rdb.

From: Kumar Gala <hidden>
Date: 2011-08-10 17:02:00

On Aug 10, 2011, at 11:27 AM, Robin Holt wrote:
I added a simple clock source for the p1010rdb so the flexcan driver
could determine a clock frequency.  The p1010 flexcan device only has
an oscillator of system bus frequency divided by 2.
=20
Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>,
Acked-by: Wolfgang Grandegger <redacted>,
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de,
Cc: netdev@vger.kernel.org,
Cc: PPC list <redacted>
Cc: Kumar Gala <redacted>
---
arch/powerpc/platforms/85xx/Kconfig    |    2 +
arch/powerpc/platforms/85xx/Makefile   |    2 +
arch/powerpc/platforms/85xx/clock.c    |   52 =
++++++++++++++++++++++++++++++++
arch/powerpc/platforms/85xx/p1010rdb.c |    8 +++++
4 files changed, 64 insertions(+), 0 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/clock.c
I dont understand how mpc85xx_clk_functions() ends up being associated =
with the frequency the flexcan is running at.

This either seems to global or I'm missing something.

I still think the clk / freq info should be in the device tree and =
handled in the driver and NOT arch/powerpc platform code.

- k=

Re: [PATCH v11 4/5] powerpc: Add flexcan device support for p1010rdb.

From: Wolfgang Grandegger <hidden>
Date: 2011-08-10 18:16:39

On 08/10/2011 07:01 PM, Kumar Gala wrote:
On Aug 10, 2011, at 11:27 AM, Robin Holt wrote:
quoted
I added a simple clock source for the p1010rdb so the flexcan driver
could determine a clock frequency.  The p1010 flexcan device only has
an oscillator of system bus frequency divided by 2.

Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>,
Acked-by: Wolfgang Grandegger <redacted>,
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de,
Cc: netdev@vger.kernel.org,
Cc: PPC list <redacted>
Cc: Kumar Gala <redacted>
---
arch/powerpc/platforms/85xx/Kconfig    |    2 +
arch/powerpc/platforms/85xx/Makefile   |    2 +
arch/powerpc/platforms/85xx/clock.c    |   52 ++++++++++++++++++++++++++++++++
arch/powerpc/platforms/85xx/p1010rdb.c |    8 +++++
4 files changed, 64 insertions(+), 0 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/clock.c
I dont understand how mpc85xx_clk_functions() ends up being associated with the frequency the flexcan is running at.
The function mpc85xx_clk_get_rate() returns "fsl_get_sys_freq() / 2" for
Flexcan devices.
This either seems to global or I'm missing something.
This patch extends the existing Flexcan platform driver for ARM for the
PowerPC using the device tree. Due to the nice integration of the device
tree (of-platform) into the platform driver and devices, the difference
are quite small (see patches 1..3). Apart from the endianess issue, only
the clock needs to be handled in a common way. As ARM already uses the
clk interface, we found it straight-forward to implement it for the
P1010, or more general for the 85xx, as well, instead of using an
additional helper function.
I still think the clk / freq info should be in the device tree and handled in the driver and NOT arch/powerpc platform code.
If I understand you correctly, you want the boot-loader to provide the
relevant information by fixing up the device tree, which then can be
handled arch-independently by the driver, right?

Wolfgang.

Re: [PATCH v11 4/5] powerpc: Add flexcan device support for p1010rdb.

From: Robin Holt <hidden>
Date: 2011-08-11 03:56:23

On Wed, Aug 10, 2011 at 08:16:33PM +0200, Wolfgang Grandegger wrote:
On 08/10/2011 07:01 PM, Kumar Gala wrote:
quoted
On Aug 10, 2011, at 11:27 AM, Robin Holt wrote:
quoted
I added a simple clock source for the p1010rdb so the flexcan driver
could determine a clock frequency.  The p1010 flexcan device only has
an oscillator of system bus frequency divided by 2.

Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>,
Acked-by: Wolfgang Grandegger <redacted>,
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de,
Cc: netdev@vger.kernel.org,
Cc: PPC list <redacted>
Cc: Kumar Gala <redacted>
---
arch/powerpc/platforms/85xx/Kconfig    |    2 +
arch/powerpc/platforms/85xx/Makefile   |    2 +
arch/powerpc/platforms/85xx/clock.c    |   52 ++++++++++++++++++++++++++++++++
arch/powerpc/platforms/85xx/p1010rdb.c |    8 +++++
4 files changed, 64 insertions(+), 0 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/clock.c
I dont understand how mpc85xx_clk_functions() ends up being associated with the frequency the flexcan is running at.
The function mpc85xx_clk_get_rate() returns "fsl_get_sys_freq() / 2" for
Flexcan devices.
quoted
This either seems to global or I'm missing something.
This patch extends the existing Flexcan platform driver for ARM for the
PowerPC using the device tree. Due to the nice integration of the device
tree (of-platform) into the platform driver and devices, the difference
are quite small (see patches 1..3). Apart from the endianess issue, only
the clock needs to be handled in a common way. As ARM already uses the
clk interface, we found it straight-forward to implement it for the
P1010, or more general for the 85xx, as well, instead of using an
additional helper function.
quoted
I still think the clk / freq info should be in the device tree and handled in the driver and NOT arch/powerpc platform code.
If I understand you correctly, you want the boot-loader to provide the
relevant information by fixing up the device tree, which then can be
handled arch-independently by the driver, right?
Marc and Wolfgang,

This is a very early swag at this which I worked up while driving home from dinner
this evening.  It works with my current config, but that includes at least one
bogus patch.  I will have to do more testing tomorrow.  For now, it is something
to ponder.

Thanks,
Robin
------------------------------------------------------------------------

flexcan: Prefer device tree clock frequency if available.

If our CAN device's device tree node has a clock-frequency property,
then use that value for the can devices clock frequency.  If not, fall
back to asking the platform/mach code for the clock frequency associated
with the flexcan device.

Too-early-to-be-signed-off-by: Robin Holt [off-list ref]
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 662f832..d6a87c9 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -33,6 +33,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 
 #define DRV_NAME			"flexcan"
@@ -929,12 +930,25 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
 	void __iomem *base;
 	resource_size_t mem_size;
 	int err, irq;
+	u32 clock_freq = 0;
 
-	clk = clk_get(&pdev->dev, NULL);
-	if (IS_ERR(clk)) {
-		dev_err(&pdev->dev, "no clock defined\n");
-		err = PTR_ERR(clk);
-		goto failed_clock;
+	if (pdev->dev.of_node) {
+		u32 *clock_freq_p;
+
+		clk = NULL;
+		clock_freq_p = (u32 *)of_get_property(pdev->dev.of_node, "clock-frequency", NULL);
+		if (clock_freq_p)
+			clock_freq = *clock_freq_p;
+	}
+
+	if (clock_freq) {
+		clk = clk_get(&pdev->dev, NULL);
+		if (IS_ERR(clk)) {
+			dev_err(&pdev->dev, "no clock defined\n");
+			err = PTR_ERR(clk);
+			goto failed_clock;
+		}
+		clock_freq = clk_get_rate(clk);
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -967,7 +981,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
 	dev->flags |= IFF_ECHO; /* we support local echo in hardware */
 
 	priv = netdev_priv(dev);
-	priv->can.clock.freq = clk_get_rate(clk);
+	priv->can.clock.freq = clock_freq;
 	priv->can.bittiming_const = &flexcan_bittiming_const;
 	priv->can.do_set_mode = flexcan_set_mode;
 	priv->can.do_get_berr_counter = flexcan_get_berr_counter;
@@ -1002,7 +1016,8 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
  failed_map:
 	release_mem_region(mem->start, mem_size);
  failed_get:
-	clk_put(clk);
+	if (clk)
+		clk_put(clk);
  failed_clock:
 	return err;
 }
@@ -1020,7 +1035,8 @@ static int __devexit flexcan_remove(struct platform_device *pdev)
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	release_mem_region(mem->start, resource_size(mem));
 
-	clk_put(priv->clk);
+	if (priv->clk)
+		clk_put(priv->clk);
 
 	free_candev(dev);
 

Re: [PATCH v11 4/5] powerpc: Add flexcan device support for p1010rdb.

From: Kumar Gala <hidden>
Date: 2011-08-11 04:46:39

On Aug 10, 2011, at 1:16 PM, Wolfgang Grandegger wrote:
On 08/10/2011 07:01 PM, Kumar Gala wrote:
quoted
=20
On Aug 10, 2011, at 11:27 AM, Robin Holt wrote:
=20
quoted
I added a simple clock source for the p1010rdb so the flexcan driver
could determine a clock frequency.  The p1010 flexcan device only =
has
quoted
quoted
an oscillator of system bus frequency divided by 2.
=20
Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>,
Acked-by: Wolfgang Grandegger <redacted>,
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de,
Cc: netdev@vger.kernel.org,
Cc: PPC list <redacted>
Cc: Kumar Gala <redacted>
---
arch/powerpc/platforms/85xx/Kconfig    |    2 +
arch/powerpc/platforms/85xx/Makefile   |    2 +
arch/powerpc/platforms/85xx/clock.c    |   52 =
++++++++++++++++++++++++++++++++
quoted
quoted
arch/powerpc/platforms/85xx/p1010rdb.c |    8 +++++
4 files changed, 64 insertions(+), 0 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/clock.c
=20
I dont understand how mpc85xx_clk_functions() ends up being =
associated with the frequency the flexcan is running at.
=20
The function mpc85xx_clk_get_rate() returns "fsl_get_sys_freq() / 2" =
for
Flexcan devices.
=20
quoted
This either seems to global or I'm missing something.
=20
This patch extends the existing Flexcan platform driver for ARM for =
the
PowerPC using the device tree. Due to the nice integration of the =
device
tree (of-platform) into the platform driver and devices, the =
difference
are quite small (see patches 1..3). Apart from the endianess issue, =
only
the clock needs to be handled in a common way. As ARM already uses the
clk interface, we found it straight-forward to implement it for the
P1010, or more general for the 85xx, as well, instead of using an
additional helper function.
I see, that.  What concerns me is there are numerous clocks / =
frequencies that exist inside a MPC85xx/P1010 SOC.  The code I'm seeing =
does NOT seem to do anything to relate this clock JUST to the flexcan.
quoted
I still think the clk / freq info should be in the device tree and =
handled in the driver and NOT arch/powerpc platform code.
=20
If I understand you correctly, you want the boot-loader to provide the
relevant information by fixing up the device tree, which then can be
handled arch-independently by the driver, right?
Yes, that is part of what I want.

- k=

Re: [PATCH v11 4/5] powerpc: Add flexcan device support for p1010rdb.

From: Wolfgang Grandegger <hidden>
Date: 2011-08-11 07:26:35

On 08/11/2011 06:46 AM, Kumar Gala wrote:
On Aug 10, 2011, at 1:16 PM, Wolfgang Grandegger wrote:
quoted
On 08/10/2011 07:01 PM, Kumar Gala wrote:
quoted
On Aug 10, 2011, at 11:27 AM, Robin Holt wrote:
quoted
I added a simple clock source for the p1010rdb so the flexcan driver
could determine a clock frequency.  The p1010 flexcan device only has
an oscillator of system bus frequency divided by 2.

Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>,
Acked-by: Wolfgang Grandegger <redacted>,
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de,
Cc: netdev@vger.kernel.org,
Cc: PPC list <redacted>
Cc: Kumar Gala <redacted>
---
arch/powerpc/platforms/85xx/Kconfig    |    2 +
arch/powerpc/platforms/85xx/Makefile   |    2 +
arch/powerpc/platforms/85xx/clock.c    |   52 ++++++++++++++++++++++++++++++++
arch/powerpc/platforms/85xx/p1010rdb.c |    8 +++++
4 files changed, 64 insertions(+), 0 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/clock.c
I dont understand how mpc85xx_clk_functions() ends up being associated with the frequency the flexcan is running at.
The function mpc85xx_clk_get_rate() returns "fsl_get_sys_freq() / 2" for
Flexcan devices.
quoted
This either seems to global or I'm missing something.
This patch extends the existing Flexcan platform driver for ARM for the
PowerPC using the device tree. Due to the nice integration of the device
tree (of-platform) into the platform driver and devices, the difference
are quite small (see patches 1..3). Apart from the endianess issue, only
the clock needs to be handled in a common way. As ARM already uses the
clk interface, we found it straight-forward to implement it for the
P1010, or more general for the 85xx, as well, instead of using an
additional helper function.
I see, that.  What concerns me is there are numerous clocks / frequencies that exist inside a MPC85xx/P1010 SOC.  The code I'm seeing does NOT seem to do anything to relate this clock JUST to the flexcan.
The clk interface is not commonly used on PowerPC, I know. It's just to
provide compatibility with ARM. An alternative would be to use some
helper function.
quoted
quoted
I still think the clk / freq info should be in the device tree and handled in the driver and NOT arch/powerpc platform code.
If I understand you correctly, you want the boot-loader to provide the
relevant information by fixing up the device tree, which then can be
handled arch-independently by the driver, right?
Yes, that is part of what I want.
This works fine if we just have *one* fixed clock source and frequency.
When there are choices (source and divider) it does make sense to allow
the user to select the frequency via DTS file entries for Linux. Then we
need arch-specific code anyway (to set the relevant registers).
Furthermore we rely on the boot-loader (the usual argument) which is not
a problem for new boards (with new boot-loader), of course.

Wolfgang.

Re: [PATCH v11 4/5] powerpc: Add flexcan device support for p1010rdb.

From: Wolfgang Grandegger <hidden>
Date: 2011-08-11 07:35:43

On 08/11/2011 05:56 AM, Robin Holt wrote:
On Wed, Aug 10, 2011 at 08:16:33PM +0200, Wolfgang Grandegger wrote:
quoted
On 08/10/2011 07:01 PM, Kumar Gala wrote:
quoted
On Aug 10, 2011, at 11:27 AM, Robin Holt wrote:
quoted
I added a simple clock source for the p1010rdb so the flexcan driver
could determine a clock frequency.  The p1010 flexcan device only has
an oscillator of system bus frequency divided by 2.

Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>,
Acked-by: Wolfgang Grandegger <redacted>,
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de,
Cc: netdev@vger.kernel.org,
Cc: PPC list <redacted>
Cc: Kumar Gala <redacted>
---
arch/powerpc/platforms/85xx/Kconfig    |    2 +
arch/powerpc/platforms/85xx/Makefile   |    2 +
arch/powerpc/platforms/85xx/clock.c    |   52 ++++++++++++++++++++++++++++++++
arch/powerpc/platforms/85xx/p1010rdb.c |    8 +++++
4 files changed, 64 insertions(+), 0 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/clock.c
I dont understand how mpc85xx_clk_functions() ends up being associated with the frequency the flexcan is running at.
The function mpc85xx_clk_get_rate() returns "fsl_get_sys_freq() / 2" for
Flexcan devices.
quoted
This either seems to global or I'm missing something.
This patch extends the existing Flexcan platform driver for ARM for the
PowerPC using the device tree. Due to the nice integration of the device
tree (of-platform) into the platform driver and devices, the difference
are quite small (see patches 1..3). Apart from the endianess issue, only
the clock needs to be handled in a common way. As ARM already uses the
clk interface, we found it straight-forward to implement it for the
P1010, or more general for the 85xx, as well, instead of using an
additional helper function.
quoted
I still think the clk / freq info should be in the device tree and handled in the driver and NOT arch/powerpc platform code.
If I understand you correctly, you want the boot-loader to provide the
relevant information by fixing up the device tree, which then can be
handled arch-independently by the driver, right?
Marc and Wolfgang,

This is a very early swag at this which I worked up while driving home from dinner
this evening.  It works with my current config, but that includes at least one
bogus patch.  I will have to do more testing tomorrow.  For now, it is something
to ponder.
Yes, that's what Kumar is proposing. Fine for me with the P1010. It just
needs some proper U-Boot implementation.
quoted hunk
Thanks,
Robin
------------------------------------------------------------------------

flexcan: Prefer device tree clock frequency if available.

If our CAN device's device tree node has a clock-frequency property,
then use that value for the can devices clock frequency.  If not, fall
back to asking the platform/mach code for the clock frequency associated
with the flexcan device.

Too-early-to-be-signed-off-by: Robin Holt [off-list ref]
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 662f832..d6a87c9 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -33,6 +33,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 
 #define DRV_NAME			"flexcan"
@@ -929,12 +930,25 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
 	void __iomem *base;
 	resource_size_t mem_size;
 	int err, irq;
+	u32 clock_freq = 0;
 
-	clk = clk_get(&pdev->dev, NULL);
-	if (IS_ERR(clk)) {
-		dev_err(&pdev->dev, "no clock defined\n");
-		err = PTR_ERR(clk);
-		goto failed_clock;
+	if (pdev->dev.of_node) {
+		u32 *clock_freq_p;
Should be:

		const u32 *clock_freq_p;
+
+		clk = NULL;
+		clock_freq_p = (u32 *)of_get_property(pdev->dev.of_node, "clock-frequency", NULL);
No cast please.
+		if (clock_freq_p)
+			clock_freq = *clock_freq_p;
+	}
Wolfgang.

Re: [PATCH v11 4/5] powerpc: Add flexcan device support for p1010rdb.

From: Robin Holt <hidden>
Date: 2011-08-11 10:42:56

On Wed, Aug 10, 2011 at 11:46:27PM -0500, Kumar Gala wrote:
On Aug 10, 2011, at 1:16 PM, Wolfgang Grandegger wrote:
quoted
On 08/10/2011 07:01 PM, Kumar Gala wrote:
quoted
On Aug 10, 2011, at 11:27 AM, Robin Holt wrote:
quoted
I added a simple clock source for the p1010rdb so the flexcan driver
could determine a clock frequency.  The p1010 flexcan device only has
an oscillator of system bus frequency divided by 2.

Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>,
Acked-by: Wolfgang Grandegger <redacted>,
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de,
Cc: netdev@vger.kernel.org,
Cc: PPC list <redacted>
Cc: Kumar Gala <redacted>
---
arch/powerpc/platforms/85xx/Kconfig    |    2 +
arch/powerpc/platforms/85xx/Makefile   |    2 +
arch/powerpc/platforms/85xx/clock.c    |   52 ++++++++++++++++++++++++++++++++
arch/powerpc/platforms/85xx/p1010rdb.c |    8 +++++
4 files changed, 64 insertions(+), 0 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/clock.c
I dont understand how mpc85xx_clk_functions() ends up being associated with the frequency the flexcan is running at.
The function mpc85xx_clk_get_rate() returns "fsl_get_sys_freq() / 2" for
Flexcan devices.
quoted
This either seems to global or I'm missing something.
This patch extends the existing Flexcan platform driver for ARM for the
PowerPC using the device tree. Due to the nice integration of the device
tree (of-platform) into the platform driver and devices, the difference
are quite small (see patches 1..3). Apart from the endianess issue, only
the clock needs to be handled in a common way. As ARM already uses the
clk interface, we found it straight-forward to implement it for the
P1010, or more general for the 85xx, as well, instead of using an
additional helper function.
I see, that.  What concerns me is there are numerous clocks /
frequencies that exist inside a MPC85xx/P1010 SOC.  The code I'm seeing
does NOT seem to do anything to relate this clock JUST to the flexcan.
        if (!dev->of_node ||
            !of_device_is_compatible(dev->of_node, "fsl,flexcan"))
                return ERR_PTR(-ENOENT);

That should relate it just to flexcan, right?  Plus it has the added
benefit of being a baby-step in the direction of implementing a clkdev
type thing for powerpc which did look fairly slick to me, but I may
be confused.

It sounds like Wolfgang is defering to you.  Give it an honest evaluation
and tell me which direction you would like me to go.  I don't have a
strong preference either way.  The alternative I gave to Wolfgang of
using a flexcan property to avoid needing any clk_get_rate seems fairly
hackish at this point, but I have had more time to get used to the
'hack in a 85xx clock' method.

Thanks,
Robin

Re: [PATCH v11 4/5] powerpc: Add flexcan device support for p1010rdb.

From: Kumar Gala <hidden>
Date: 2011-08-11 14:17:58

On Aug 11, 2011, at 5:42 AM, Robin Holt wrote:
On Wed, Aug 10, 2011 at 11:46:27PM -0500, Kumar Gala wrote:
quoted
=20
On Aug 10, 2011, at 1:16 PM, Wolfgang Grandegger wrote:
=20
quoted
On 08/10/2011 07:01 PM, Kumar Gala wrote:
quoted
=20
On Aug 10, 2011, at 11:27 AM, Robin Holt wrote:
=20
quoted
I added a simple clock source for the p1010rdb so the flexcan =
driver
quoted
quoted
quoted
quoted
could determine a clock frequency.  The p1010 flexcan device only =
has
quoted
quoted
quoted
quoted
an oscillator of system bus frequency divided by 2.
=20
Signed-off-by: Robin Holt <redacted>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>,
Acked-by: Wolfgang Grandegger <redacted>,
Cc: U Bhaskar-B22300 <redacted>
Cc: socketcan-core@lists.berlios.de,
Cc: netdev@vger.kernel.org,
Cc: PPC list <redacted>
Cc: Kumar Gala <redacted>
---
arch/powerpc/platforms/85xx/Kconfig    |    2 +
arch/powerpc/platforms/85xx/Makefile   |    2 +
arch/powerpc/platforms/85xx/clock.c    |   52 =
++++++++++++++++++++++++++++++++
quoted
quoted
quoted
quoted
arch/powerpc/platforms/85xx/p1010rdb.c |    8 +++++
4 files changed, 64 insertions(+), 0 deletions(-)
create mode 100644 arch/powerpc/platforms/85xx/clock.c
=20
I dont understand how mpc85xx_clk_functions() ends up being =
associated with the frequency the flexcan is running at.
quoted
quoted
=20
The function mpc85xx_clk_get_rate() returns "fsl_get_sys_freq() / 2" =
for
quoted
quoted
Flexcan devices.
=20
quoted
This either seems to global or I'm missing something.
=20
This patch extends the existing Flexcan platform driver for ARM for =
the
quoted
quoted
PowerPC using the device tree. Due to the nice integration of the =
device
quoted
quoted
tree (of-platform) into the platform driver and devices, the =
difference
quoted
quoted
are quite small (see patches 1..3). Apart from the endianess issue, =
only
quoted
quoted
the clock needs to be handled in a common way. As ARM already uses =
the
quoted
quoted
clk interface, we found it straight-forward to implement it for the
P1010, or more general for the 85xx, as well, instead of using an
additional helper function.
=20
I see, that.  What concerns me is there are numerous clocks /
frequencies that exist inside a MPC85xx/P1010 SOC.  The code I'm =
seeing
quoted
does NOT seem to do anything to relate this clock JUST to the =
flexcan.
=20
       if (!dev->of_node ||
           !of_device_is_compatible(dev->of_node, "fsl,flexcan"))
               return ERR_PTR(-ENOENT);
=20
That should relate it just to flexcan, right?  Plus it has the added
benefit of being a baby-step in the direction of implementing a clkdev
type thing for powerpc which did look fairly slick to me, but I may
be confused.
=20
It sounds like Wolfgang is defering to you.  Give it an honest =
evaluation
and tell me which direction you would like me to go.  I don't have a
strong preference either way.  The alternative I gave to Wolfgang of
using a flexcan property to avoid needing any clk_get_rate seems =
fairly
hackish at this point, but I have had more time to get used to the
'hack in a 85xx clock' method.
For some time we've been adding 'clock-frequency' nodes in the device =
tree to abstract having to know this headache in the kernel and adding a =
bunch of SoC specific code all the time.  So pushing this to the =
firmware is exactly where we want it for FSL PPC SoCs.

We need to make sure the device tree binding has details on a =
'clock-frequency' property.

- k=
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help