* Re: [PATCH 3/13] pmac-zilog: cleanup
From: Benjamin Herrenschmidt @ 2009-11-17 2:07 UTC (permalink / raw)
To: Finn Thain; +Cc: linuxppc-dev, linux-m68k, Geert Uytterhoeven
In-Reply-To: <alpine.OSX.2.00.0911031441280.483@silk.local>
On Wed, 2009-11-04 at 00:40 +1100, Finn Thain wrote:
> Whitespace cleanups and comment typo fix.
>
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Hi Finn. Do you want me to carry and merge those patches via the powerpc
tree ?
Cheers,
Ben.
^ permalink raw reply
* Re: [PATCH 10/13] mac68k: start CUDA early
From: Benjamin Herrenschmidt @ 2009-11-17 2:03 UTC (permalink / raw)
To: Finn Thain; +Cc: linuxppc-dev, linux-m68k, Geert Uytterhoeven
In-Reply-To: <alpine.OSX.2.00.0911031502250.483@silk.local>
On Wed, 2009-11-04 at 00:46 +1100, Finn Thain wrote:
> The valkyriefb driver needs the CUDA to work in order to set the video
> mode at boot. Initialising the device earlier, and bring the m68k code
> closer to the powermac code.
>
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Hi Finn !
> @@ -224,20 +249,9 @@ cuda_probe(void)
> static int __init
> cuda_init(void)
> {
> -#ifdef CONFIG_PPC
> if (via == NULL)
> return -ENODEV;
> return 0;
> -#else
> - int err = cuda_init_via();
> - if (err) {
> - printk(KERN_ERR "cuda_init_via() failed\n");
> - return -ENODEV;
> - }
> - out_8(&via[IER], IER_SET|SR_INT); /* enable interrupt from SR */
> -
> - return via_cuda_start();
> -#endif
> }
> #endif /* CONFIG_ADB */
Can't we just get rid of cuda_init() completely ?
> @@ -430,9 +444,12 @@ cuda_poll(void)
> /* cuda_interrupt only takes a normal lock, we disable
> * interrupts here to avoid re-entering and thus deadlocking.
> */
> - disable_irq(cuda_irq);
> - cuda_interrupt(0, NULL);
> - enable_irq(cuda_irq);
> + if (cuda_fully_inited) {
> + disable_irq(cuda_irq);
> + cuda_interrupt(0, NULL);
> + enable_irq(cuda_irq);
> + } else
> + cuda_interrupt(0, NULL);
> }
Wouldn't it be better that way ?
if (cuda_irq)
disable_irq(cuda_irq);
cuda_interrupt(0, NULL);
if (cuda_irq)
enable_irq(cuda_irq);
Cheers,
Ben.
^ permalink raw reply
* Re: [PATCH 00/10] Fix 8xx MMU/TLB
From: Scott Wood @ 2009-11-17 0:40 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: linuxppc-dev@ozlabs.org, Rex Feany
In-Reply-To: <OF8A8D1539.83855DA3-ONC1257670.007D4AD1-C1257670.007DC74A@transmode.se>
Joakim Tjernlund wrote:
> Scott Wood <scottwood@freescale.com> wrote on 16/11/2009 22:27:41:
>> On Mon, Nov 16, 2009 at 03:00:09PM -0600, Scott Wood wrote:
>>> On Sun, Nov 15, 2009 at 06:09:27PM +0100, Joakim Tjernlund wrote:
>>>> [I used the wrong branch, this will hopefully not conflict]
>>>>
>>>> This is hopfully the last iteration of the series.
>>>> Rex & Scott, please test and signoff.
>>>> Changes since last version:
>>>> - Added mandatory pinning of iTLB
>>>> - Added "DTLB Miss cleanup"
>>> I still get the EFAULTs.
>
> umm, this worked before this series with your own
> version, right?
No... I only meant that the ITLB pinning got rid of the boot hang.
When I mentioned the EFAULTs before you said, "No surprise as the it
seems like the DAR decoding is broken." I thought you meant you'd found
a bug and fixed it in this respin.
> Did I screw up with the "DTLB Miss cleanup"?
No change if I remove that patch.
> Does the self modifying code version work any better?
No change.
-Scott
^ permalink raw reply
* [PATCH 11/11] net/can/mscan: improve build
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
- move Kconfig entries to the subdirectory
- do remaining renames of mpc52xx to mpc5xxx
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/can/Kconfig | 19 +---
drivers/net/can/mscan/Kconfig | 23 +++
drivers/net/can/mscan/Makefile | 4 +-
drivers/net/can/mscan/mpc52xx_can.c | 259 -----------------------------------
drivers/net/can/mscan/mpc5xxx_can.c | 259 +++++++++++++++++++++++++++++++++++
5 files changed, 285 insertions(+), 279 deletions(-)
create mode 100644 drivers/net/can/mscan/Kconfig
delete mode 100644 drivers/net/can/mscan/mpc52xx_can.c
create mode 100644 drivers/net/can/mscan/mpc5xxx_can.c
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
index c16e6ff..c1cfe2e 100644
--- a/drivers/net/can/Kconfig
+++ b/drivers/net/can/Kconfig
@@ -108,24 +108,7 @@ config CAN_MCP251X
---help---
Driver for the Microchip MCP251x SPI CAN controllers.
-config CAN_MSCAN
- depends on CAN_DEV && (PPC || M68K || M68KNOMMU)
- tristate "Support for Freescale MSCAN based chips"
- ---help---
- The Motorola Scalable Controller Area Network (MSCAN) definition
- is based on the MSCAN12 definition which is the specific
- implementation of the Motorola Scalable CAN concept targeted for
- the Motorola MC68HC12 Microcontroller Family.
-
-config CAN_MPC52XX
- tristate "Freescale MPC5xxx onboard CAN controller"
- depends on CAN_MSCAN && PPC_MPC52xx
- ---help---
- If you say yes here you get support for Freescale's MPC52xx
- onboard dualCAN controller.
-
- This driver can also be built as a module. If so, the module
- will be called mpc5xxx_can.
+source "drivers/net/can/mscan/Kconfig"
config CAN_DEBUG_DEVICES
bool "CAN devices debugging messages"
diff --git a/drivers/net/can/mscan/Kconfig b/drivers/net/can/mscan/Kconfig
new file mode 100644
index 0000000..cd0f2d6
--- /dev/null
+++ b/drivers/net/can/mscan/Kconfig
@@ -0,0 +1,23 @@
+config CAN_MSCAN
+ depends on CAN_DEV && (PPC || M68K || M68KNOMMU)
+ tristate "Support for Freescale MSCAN based chips"
+ ---help---
+ The Motorola Scalable Controller Area Network (MSCAN) definition
+ is based on the MSCAN12 definition which is the specific
+ implementation of the Motorola Scalable CAN concept targeted for
+ the Motorola MC68HC12 Microcontroller Family.
+
+if CAN_MSCAN
+
+config CAN_MPC5XXX
+ tristate "Freescale MPC5xxx onboard CAN controller"
+ depends on PPC_MPC52xx
+ ---help---
+ If you say yes here you get support for Freescale's MPC5xxx
+ onboard CAN controller.
+
+ This driver can also be built as a module. If so, the module
+ will be called mscan-mpc5xxx.ko.
+
+endif
+
diff --git a/drivers/net/can/mscan/Makefile b/drivers/net/can/mscan/Makefile
index 2bd9f04..c9fab17 100644
--- a/drivers/net/can/mscan/Makefile
+++ b/drivers/net/can/mscan/Makefile
@@ -1,5 +1,5 @@
-obj-$(CONFIG_CAN_MPC52XX) += mscan-mpc52xx.o
-mscan-mpc52xx-objs := mscan.o mpc52xx_can.o
+obj-$(CONFIG_CAN_MPC5XXX) += mscan-mpc5xxx.o
+mscan-mpc5xxx-objs := mscan.o mpc5xxx_can.o
ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG
diff --git a/drivers/net/can/mscan/mpc52xx_can.c b/drivers/net/can/mscan/mpc52xx_can.c
deleted file mode 100644
index 1de6f63..0000000
--- a/drivers/net/can/mscan/mpc52xx_can.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * CAN bus driver for the Freescale MPC5xxx embedded CPU.
- *
- * Copyright (C) 2004-2005 Andrey Volkov <avolkov@varma-el.com>,
- * Varma Electronics Oy
- * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
- * Copyright (C) 2009 Wolfram Sang, Pengutronix <w.sang@pengutronix.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the version 2 of the GNU General Public License
- * as published by the Free Software Foundation
- *
- * 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
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/interrupt.h>
-#include <linux/platform_device.h>
-#include <linux/netdevice.h>
-#include <linux/can.h>
-#include <linux/can/dev.h>
-#include <linux/of_platform.h>
-#include <sysdev/fsl_soc.h>
-#include <linux/io.h>
-#include <asm/mpc52xx.h>
-
-#include "mscan.h"
-
-#define DRV_NAME "mpc5xxx_can"
-
-static struct of_device_id mpc52xx_cdm_ids[] __devinitdata = {
- { .compatible = "fsl,mpc5200-cdm", },
- {}
-};
-
-/*
- * Get frequency of the MSCAN clock source
- *
- * Either the oscillator clock (SYS_XTAL_IN) or the IP bus clock (IP_CLK)
- * can be selected. According to the MPC5200 user's manual, the oscillator
- * clock is the better choice as it has less jitter but due to a hardware
- * bug, it can not be selected for the old MPC5200 Rev. A chips.
- */
-
-static unsigned int __devinit mpc52xx_can_clock_freq(struct of_device *of,
- int clock_src)
-{
- unsigned int pvr;
- struct mpc52xx_cdm __iomem *cdm;
- struct device_node *np_cdm;
- unsigned int freq;
- u32 val;
-
- pvr = mfspr(SPRN_PVR);
-
- freq = mpc5xxx_get_bus_frequency(of->node);
- if (!freq)
- return 0;
-
- if (clock_src == MSCAN_CLKSRC_BUS || pvr == 0x80822011)
- return freq;
-
- /* Determine SYS_XTAL_IN frequency from the clock domain settings */
- np_cdm = of_find_matching_node(NULL, mpc52xx_cdm_ids);
- if (!np_cdm) {
- dev_err(&of->dev, "can't get clock node!\n");
- return 0;
- }
- cdm = of_iomap(np_cdm, 0);
- of_node_put(np_cdm);
-
- if (in_8(&cdm->ipb_clk_sel) & 0x1)
- freq *= 2;
- val = in_be32(&cdm->rstcfg);
-
- freq *= (val & (1 << 5)) ? 8 : 4;
- freq /= (val & (1 << 6)) ? 12 : 16;
-
- iounmap(cdm);
-
- return freq;
-}
-
-static int __devinit mpc5xxx_can_probe(struct of_device *ofdev,
- const struct of_device_id *id)
-{
- struct device_node *np = ofdev->node;
- struct net_device *dev;
- struct mscan_priv *priv;
- void __iomem *base;
- const char *clk_src;
- int err, irq, clock_src;
-
- base = of_iomap(ofdev->node, 0);
- if (!base) {
- dev_err(&ofdev->dev, "couldn't ioremap\n");
- err = -ENOMEM;
- goto exit_release_mem;
- }
-
- irq = irq_of_parse_and_map(np, 0);
- if (!irq) {
- dev_err(&ofdev->dev, "no irq found\n");
- err = -ENODEV;
- goto exit_unmap_mem;
- }
-
- dev = alloc_mscandev();
- if (!dev) {
- err = -ENOMEM;
- goto exit_dispose_irq;
- }
-
- priv = netdev_priv(dev);
- priv->reg_base = base;
- dev->irq = irq;
-
- /*
- * Either the oscillator clock (SYS_XTAL_IN) or the IP bus clock
- * (IP_CLK) can be selected as MSCAN clock source. According to
- * the MPC5200 user's manual, the oscillator clock is the better
- * choice as it has less jitter. For this reason, it is selected
- * by default.
- */
- clk_src = of_get_property(np, "fsl,mscan-clock-source", NULL);
- if (clk_src && strcmp(clk_src, "ip") == 0)
- clock_src = MSCAN_CLKSRC_BUS;
- else
- clock_src = MSCAN_CLKSRC_XTAL;
- priv->can.clock.freq = mpc52xx_can_clock_freq(ofdev, clock_src);
- if (!priv->can.clock.freq) {
- dev_err(&ofdev->dev, "couldn't get MSCAN clock frequency\n");
- err = -ENODEV;
- goto exit_free_mscan;
- }
-
- SET_NETDEV_DEV(dev, &ofdev->dev);
-
- err = register_mscandev(dev, clock_src);
- if (err) {
- dev_err(&ofdev->dev, "registering %s failed (err=%d)\n",
- DRV_NAME, err);
- goto exit_free_mscan;
- }
-
- dev_set_drvdata(&ofdev->dev, dev);
-
- dev_info(&ofdev->dev, "MSCAN at 0x%p, irq %d, clock %d Hz\n",
- priv->reg_base, dev->irq, priv->can.clock.freq);
-
- return 0;
-
-exit_free_mscan:
- free_candev(dev);
-exit_dispose_irq:
- irq_dispose_mapping(irq);
-exit_unmap_mem:
- iounmap(base);
-exit_release_mem:
- return err;
-}
-
-static int __devexit mpc5xxx_can_remove(struct of_device *ofdev)
-{
- struct net_device *dev = dev_get_drvdata(&ofdev->dev);
- struct mscan_priv *priv = netdev_priv(dev);
-
- dev_set_drvdata(&ofdev->dev, NULL);
-
- unregister_mscandev(dev);
- iounmap(priv->reg_base);
- irq_dispose_mapping(dev->irq);
- free_candev(dev);
-
- return 0;
-}
-
-#ifdef CONFIG_PM
-static struct mscan_regs saved_regs;
-static int mpc5xxx_can_suspend(struct of_device *ofdev, pm_message_t state)
-{
- struct net_device *dev = dev_get_drvdata(&ofdev->dev);
- struct mscan_priv *priv = netdev_priv(dev);
- struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
-
- _memcpy_fromio(&saved_regs, regs, sizeof(*regs));
-
- return 0;
-}
-
-static int mpc5xxx_can_resume(struct of_device *ofdev)
-{
- struct net_device *dev = dev_get_drvdata(&ofdev->dev);
- struct mscan_priv *priv = netdev_priv(dev);
- struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
-
- regs->canctl0 |= MSCAN_INITRQ;
- while (!(regs->canctl1 & MSCAN_INITAK))
- udelay(10);
-
- regs->canctl1 = saved_regs.canctl1;
- regs->canbtr0 = saved_regs.canbtr0;
- regs->canbtr1 = saved_regs.canbtr1;
- regs->canidac = saved_regs.canidac;
-
- /* restore masks, buffers etc. */
- _memcpy_toio(®s->canidar1_0, (void *)&saved_regs.canidar1_0,
- sizeof(*regs) - offsetof(struct mscan_regs, canidar1_0));
-
- regs->canctl0 &= ~MSCAN_INITRQ;
- regs->cantbsel = saved_regs.cantbsel;
- regs->canrier = saved_regs.canrier;
- regs->cantier = saved_regs.cantier;
- regs->canctl0 = saved_regs.canctl0;
-
- return 0;
-}
-#endif
-
-static struct of_device_id __devinitdata mpc5xxx_can_table[] = {
- {.compatible = "fsl,mpc5200-mscan"},
- {},
-};
-
-static struct of_platform_driver mpc5xxx_can_driver = {
- .owner = THIS_MODULE,
- .name = "mpc5xxx_can",
- .probe = mpc5xxx_can_probe,
- .remove = __devexit_p(mpc5xxx_can_remove),
-#ifdef CONFIG_PM
- .suspend = mpc5xxx_can_suspend,
- .resume = mpc5xxx_can_resume,
-#endif
- .match_table = mpc5xxx_can_table,
-};
-
-static int __init mpc5xxx_can_init(void)
-{
- return of_register_platform_driver(&mpc5xxx_can_driver);
-}
-module_init(mpc5xxx_can_init);
-
-static void __exit mpc5xxx_can_exit(void)
-{
- return of_unregister_platform_driver(&mpc5xxx_can_driver);
-};
-module_exit(mpc5xxx_can_exit);
-
-MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>");
-MODULE_DESCRIPTION("Freescale MPC5200 CAN driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
new file mode 100644
index 0000000..1de6f63
--- /dev/null
+++ b/drivers/net/can/mscan/mpc5xxx_can.c
@@ -0,0 +1,259 @@
+/*
+ * CAN bus driver for the Freescale MPC5xxx embedded CPU.
+ *
+ * Copyright (C) 2004-2005 Andrey Volkov <avolkov@varma-el.com>,
+ * Varma Electronics Oy
+ * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
+ * Copyright (C) 2009 Wolfram Sang, Pengutronix <w.sang@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the version 2 of the GNU General Public License
+ * as published by the Free Software Foundation
+ *
+ * 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
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/netdevice.h>
+#include <linux/can.h>
+#include <linux/can/dev.h>
+#include <linux/of_platform.h>
+#include <sysdev/fsl_soc.h>
+#include <linux/io.h>
+#include <asm/mpc52xx.h>
+
+#include "mscan.h"
+
+#define DRV_NAME "mpc5xxx_can"
+
+static struct of_device_id mpc52xx_cdm_ids[] __devinitdata = {
+ { .compatible = "fsl,mpc5200-cdm", },
+ {}
+};
+
+/*
+ * Get frequency of the MSCAN clock source
+ *
+ * Either the oscillator clock (SYS_XTAL_IN) or the IP bus clock (IP_CLK)
+ * can be selected. According to the MPC5200 user's manual, the oscillator
+ * clock is the better choice as it has less jitter but due to a hardware
+ * bug, it can not be selected for the old MPC5200 Rev. A chips.
+ */
+
+static unsigned int __devinit mpc52xx_can_clock_freq(struct of_device *of,
+ int clock_src)
+{
+ unsigned int pvr;
+ struct mpc52xx_cdm __iomem *cdm;
+ struct device_node *np_cdm;
+ unsigned int freq;
+ u32 val;
+
+ pvr = mfspr(SPRN_PVR);
+
+ freq = mpc5xxx_get_bus_frequency(of->node);
+ if (!freq)
+ return 0;
+
+ if (clock_src == MSCAN_CLKSRC_BUS || pvr == 0x80822011)
+ return freq;
+
+ /* Determine SYS_XTAL_IN frequency from the clock domain settings */
+ np_cdm = of_find_matching_node(NULL, mpc52xx_cdm_ids);
+ if (!np_cdm) {
+ dev_err(&of->dev, "can't get clock node!\n");
+ return 0;
+ }
+ cdm = of_iomap(np_cdm, 0);
+ of_node_put(np_cdm);
+
+ if (in_8(&cdm->ipb_clk_sel) & 0x1)
+ freq *= 2;
+ val = in_be32(&cdm->rstcfg);
+
+ freq *= (val & (1 << 5)) ? 8 : 4;
+ freq /= (val & (1 << 6)) ? 12 : 16;
+
+ iounmap(cdm);
+
+ return freq;
+}
+
+static int __devinit mpc5xxx_can_probe(struct of_device *ofdev,
+ const struct of_device_id *id)
+{
+ struct device_node *np = ofdev->node;
+ struct net_device *dev;
+ struct mscan_priv *priv;
+ void __iomem *base;
+ const char *clk_src;
+ int err, irq, clock_src;
+
+ base = of_iomap(ofdev->node, 0);
+ if (!base) {
+ dev_err(&ofdev->dev, "couldn't ioremap\n");
+ err = -ENOMEM;
+ goto exit_release_mem;
+ }
+
+ irq = irq_of_parse_and_map(np, 0);
+ if (!irq) {
+ dev_err(&ofdev->dev, "no irq found\n");
+ err = -ENODEV;
+ goto exit_unmap_mem;
+ }
+
+ dev = alloc_mscandev();
+ if (!dev) {
+ err = -ENOMEM;
+ goto exit_dispose_irq;
+ }
+
+ priv = netdev_priv(dev);
+ priv->reg_base = base;
+ dev->irq = irq;
+
+ /*
+ * Either the oscillator clock (SYS_XTAL_IN) or the IP bus clock
+ * (IP_CLK) can be selected as MSCAN clock source. According to
+ * the MPC5200 user's manual, the oscillator clock is the better
+ * choice as it has less jitter. For this reason, it is selected
+ * by default.
+ */
+ clk_src = of_get_property(np, "fsl,mscan-clock-source", NULL);
+ if (clk_src && strcmp(clk_src, "ip") == 0)
+ clock_src = MSCAN_CLKSRC_BUS;
+ else
+ clock_src = MSCAN_CLKSRC_XTAL;
+ priv->can.clock.freq = mpc52xx_can_clock_freq(ofdev, clock_src);
+ if (!priv->can.clock.freq) {
+ dev_err(&ofdev->dev, "couldn't get MSCAN clock frequency\n");
+ err = -ENODEV;
+ goto exit_free_mscan;
+ }
+
+ SET_NETDEV_DEV(dev, &ofdev->dev);
+
+ err = register_mscandev(dev, clock_src);
+ if (err) {
+ dev_err(&ofdev->dev, "registering %s failed (err=%d)\n",
+ DRV_NAME, err);
+ goto exit_free_mscan;
+ }
+
+ dev_set_drvdata(&ofdev->dev, dev);
+
+ dev_info(&ofdev->dev, "MSCAN at 0x%p, irq %d, clock %d Hz\n",
+ priv->reg_base, dev->irq, priv->can.clock.freq);
+
+ return 0;
+
+exit_free_mscan:
+ free_candev(dev);
+exit_dispose_irq:
+ irq_dispose_mapping(irq);
+exit_unmap_mem:
+ iounmap(base);
+exit_release_mem:
+ return err;
+}
+
+static int __devexit mpc5xxx_can_remove(struct of_device *ofdev)
+{
+ struct net_device *dev = dev_get_drvdata(&ofdev->dev);
+ struct mscan_priv *priv = netdev_priv(dev);
+
+ dev_set_drvdata(&ofdev->dev, NULL);
+
+ unregister_mscandev(dev);
+ iounmap(priv->reg_base);
+ irq_dispose_mapping(dev->irq);
+ free_candev(dev);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static struct mscan_regs saved_regs;
+static int mpc5xxx_can_suspend(struct of_device *ofdev, pm_message_t state)
+{
+ struct net_device *dev = dev_get_drvdata(&ofdev->dev);
+ struct mscan_priv *priv = netdev_priv(dev);
+ struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
+
+ _memcpy_fromio(&saved_regs, regs, sizeof(*regs));
+
+ return 0;
+}
+
+static int mpc5xxx_can_resume(struct of_device *ofdev)
+{
+ struct net_device *dev = dev_get_drvdata(&ofdev->dev);
+ struct mscan_priv *priv = netdev_priv(dev);
+ struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
+
+ regs->canctl0 |= MSCAN_INITRQ;
+ while (!(regs->canctl1 & MSCAN_INITAK))
+ udelay(10);
+
+ regs->canctl1 = saved_regs.canctl1;
+ regs->canbtr0 = saved_regs.canbtr0;
+ regs->canbtr1 = saved_regs.canbtr1;
+ regs->canidac = saved_regs.canidac;
+
+ /* restore masks, buffers etc. */
+ _memcpy_toio(®s->canidar1_0, (void *)&saved_regs.canidar1_0,
+ sizeof(*regs) - offsetof(struct mscan_regs, canidar1_0));
+
+ regs->canctl0 &= ~MSCAN_INITRQ;
+ regs->cantbsel = saved_regs.cantbsel;
+ regs->canrier = saved_regs.canrier;
+ regs->cantier = saved_regs.cantier;
+ regs->canctl0 = saved_regs.canctl0;
+
+ return 0;
+}
+#endif
+
+static struct of_device_id __devinitdata mpc5xxx_can_table[] = {
+ {.compatible = "fsl,mpc5200-mscan"},
+ {},
+};
+
+static struct of_platform_driver mpc5xxx_can_driver = {
+ .owner = THIS_MODULE,
+ .name = "mpc5xxx_can",
+ .probe = mpc5xxx_can_probe,
+ .remove = __devexit_p(mpc5xxx_can_remove),
+#ifdef CONFIG_PM
+ .suspend = mpc5xxx_can_suspend,
+ .resume = mpc5xxx_can_resume,
+#endif
+ .match_table = mpc5xxx_can_table,
+};
+
+static int __init mpc5xxx_can_init(void)
+{
+ return of_register_platform_driver(&mpc5xxx_can_driver);
+}
+module_init(mpc5xxx_can_init);
+
+static void __exit mpc5xxx_can_exit(void)
+{
+ return of_unregister_platform_driver(&mpc5xxx_can_driver);
+};
+module_exit(mpc5xxx_can_exit);
+
+MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>");
+MODULE_DESCRIPTION("Freescale MPC5200 CAN driver");
+MODULE_LICENSE("GPL v2");
--
1.6.3.3
^ permalink raw reply related
* [PATCH 10/11] net/can/mscan: add error path to mscan_open()
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/can/mscan/mscan.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index 263d1a9..bb06dfb 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -542,10 +542,8 @@ static int mscan_open(struct net_device *dev)
ret = request_irq(dev->irq, mscan_isr, 0, dev->name, dev);
if (ret < 0) {
- napi_disable(&priv->napi);
- printk(KERN_ERR "%s - failed to attach interrupt\n",
- dev->name);
- return ret;
+ dev_err(dev->dev.parent, "failed to attach interrupt\n");
+ goto exit_napi_disable;
}
priv->open_time = jiffies;
@@ -554,11 +552,19 @@ static int mscan_open(struct net_device *dev)
ret = mscan_start(dev);
if (ret)
- return ret;
+ goto exit_free_irq;
netif_start_queue(dev);
return 0;
+
+exit_free_irq:
+ priv->open_time = 0;
+ free_irq(dev->irq, dev);
+exit_napi_disable:
+ napi_disable(&priv->napi);
+ close_candev(dev);
+ return ret;
}
static int mscan_close(struct net_device *dev)
--
1.6.3.3
^ permalink raw reply related
* [PATCH 09/11] net/can/mscan: replace hardcoded values with defines
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
Not all hardcoded values have been replaced as this made the code quite
unreadable. IMHO this compromise serves the purpose of readability.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/can/mscan/mscan.c | 15 ++++++++++-----
drivers/net/can/mscan/mscan.h | 5 +++++
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index 20d1991..263d1a9 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -211,18 +211,23 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev)
rtr = frame->can_id & CAN_RTR_FLAG;
+ /* RTR is always the lowest bit of interest, then IDs follow */
if (frame->can_id & CAN_EFF_FLAG) {
- can_id = (frame->can_id & CAN_EFF_MASK) << 1;
+ can_id = (frame->can_id & CAN_EFF_MASK)
+ << (MSCAN_EFF_RTR_SHIFT + 1);
if (rtr)
- can_id |= 1;
+ can_id |= 1 << MSCAN_EFF_RTR_SHIFT;
out_be16(®s->tx.idr3_2, can_id);
can_id >>= 16;
- can_id = (can_id & 0x7) | ((can_id << 2) & 0xffe0) | (3 << 3);
+ /* EFF_FLAGS are inbetween the IDs :( */
+ can_id = (can_id & 0x7) | ((can_id << 2) & 0xffe0)
+ | MSCAN_EFF_FLAGS;
} else {
- can_id = (frame->can_id & CAN_SFF_MASK) << 5;
+ can_id = (frame->can_id & CAN_SFF_MASK)
+ << (MSCAN_SFF_RTR_SHIFT + 1);
if (rtr)
- can_id |= 1 << 4;
+ can_id |= 1 << MSCAN_SFF_RTR_SHIFT;
}
out_be16(®s->tx.idr1_0, can_id);
diff --git a/drivers/net/can/mscan/mscan.h b/drivers/net/can/mscan/mscan.h
index 2018000..00fc4aa 100644
--- a/drivers/net/can/mscan/mscan.h
+++ b/drivers/net/can/mscan/mscan.h
@@ -131,6 +131,11 @@
/* MSCAN Miscellaneous Register (CANMISC) bits */
#define MSCAN_BOHOLD 0x01
+/* MSCAN Identifier Register (IDR) bits */
+#define MSCAN_SFF_RTR_SHIFT 4
+#define MSCAN_EFF_RTR_SHIFT 0
+#define MSCAN_EFF_FLAGS 0x18 /* IDE + SRR */
+
#ifdef MSCAN_FOR_MPC5200
#define _MSCAN_RESERVED_(n, num) u8 _res##n[num]
#define _MSCAN_RESERVED_DSR_SIZE 2
--
1.6.3.3
^ permalink raw reply related
* [PATCH 08/11] net/can/mpc52xx_can: improve properties and their description
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: devicetree-discuss, socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: devicetree-discuss@ozlabs.org
---
Documentation/powerpc/dts-bindings/fsl/mpc5200.txt | 9 +++++----
drivers/net/can/mscan/mpc52xx_can.c | 3 +--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Documentation/powerpc/dts-bindings/fsl/mpc5200.txt b/Documentation/powerpc/dts-bindings/fsl/mpc5200.txt
index b151fb1..cabc780 100644
--- a/Documentation/powerpc/dts-bindings/fsl/mpc5200.txt
+++ b/Documentation/powerpc/dts-bindings/fsl/mpc5200.txt
@@ -181,9 +181,10 @@ External interrupts:
fsl,mpc5200-mscan nodes
-----------------------
In addition to the required compatible-, reg- and interrupt-properites, you can
-also specify which clock shall be used for the bus:
+also specify which clock source shall be used for the controller:
-- fsl,mscan-clk-src - a string describing the clock source. Valid values
- are "ip" for IP_CLK and "sys" for SYS_XTAL.
- "sys" is the default in case the property is not
+- fsl,mscan-clock-source- a string describing the clock source. Valid values
+ are: "ip" for ip bus clock
+ "ref" for reference clock (XTAL)
+ "ref" is default in case this property is not
present.
diff --git a/drivers/net/can/mscan/mpc52xx_can.c b/drivers/net/can/mscan/mpc52xx_can.c
index a915959..1de6f63 100644
--- a/drivers/net/can/mscan/mpc52xx_can.c
+++ b/drivers/net/can/mscan/mpc52xx_can.c
@@ -130,7 +130,7 @@ static int __devinit mpc5xxx_can_probe(struct of_device *ofdev,
* choice as it has less jitter. For this reason, it is selected
* by default.
*/
- clk_src = of_get_property(np, "fsl,mscan-clk-src", NULL);
+ clk_src = of_get_property(np, "fsl,mscan-clock-source", NULL);
if (clk_src && strcmp(clk_src, "ip") == 0)
clock_src = MSCAN_CLKSRC_BUS;
else
@@ -227,7 +227,6 @@ static int mpc5xxx_can_resume(struct of_device *ofdev)
static struct of_device_id __devinitdata mpc5xxx_can_table[] = {
{.compatible = "fsl,mpc5200-mscan"},
- {.compatible = "fsl,mpc5200b-mscan"},
{},
};
--
1.6.3.3
^ permalink raw reply related
* [PATCH 07/11] net/can/mpc52xx_can: refactor clock-get routine
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
Merge two functions into one. The result is smaller as they can now share some
variables.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/can/mscan/mpc52xx_can.c | 45 ++++++++++++----------------------
1 files changed, 16 insertions(+), 29 deletions(-)
diff --git a/drivers/net/can/mscan/mpc52xx_can.c b/drivers/net/can/mscan/mpc52xx_can.c
index 34ae2ba..a915959 100644
--- a/drivers/net/can/mscan/mpc52xx_can.c
+++ b/drivers/net/can/mscan/mpc52xx_can.c
@@ -38,28 +38,37 @@
static struct of_device_id mpc52xx_cdm_ids[] __devinitdata = {
{ .compatible = "fsl,mpc5200-cdm", },
- { .compatible = "fsl,mpc5200b-cdm", },
{}
};
/*
- * Get the frequency of the external oscillator clock connected
- * to the SYS_XTAL_IN pin, or return 0 if it cannot be determined.
+ * Get frequency of the MSCAN clock source
+ *
+ * Either the oscillator clock (SYS_XTAL_IN) or the IP bus clock (IP_CLK)
+ * can be selected. According to the MPC5200 user's manual, the oscillator
+ * clock is the better choice as it has less jitter but due to a hardware
+ * bug, it can not be selected for the old MPC5200 Rev. A chips.
*/
-static unsigned int __devinit mpc52xx_can_xtal_freq(struct of_device *of)
+
+static unsigned int __devinit mpc52xx_can_clock_freq(struct of_device *of,
+ int clock_src)
{
+ unsigned int pvr;
struct mpc52xx_cdm __iomem *cdm;
struct device_node *np_cdm;
unsigned int freq;
u32 val;
+ pvr = mfspr(SPRN_PVR);
+
freq = mpc5xxx_get_bus_frequency(of->node);
if (!freq)
return 0;
- /*
- * Determine SYS_XTAL_IN frequency from the clock domain settings
- */
+ if (clock_src == MSCAN_CLKSRC_BUS || pvr == 0x80822011)
+ return freq;
+
+ /* Determine SYS_XTAL_IN frequency from the clock domain settings */
np_cdm = of_find_matching_node(NULL, mpc52xx_cdm_ids);
if (!np_cdm) {
dev_err(&of->dev, "can't get clock node!\n");
@@ -80,28 +89,6 @@ static unsigned int __devinit mpc52xx_can_xtal_freq(struct of_device *of)
return freq;
}
-/*
- * Get frequency of the MSCAN clock source
- *
- * Either the oscillator clock (SYS_XTAL_IN) or the IP bus clock (IP_CLK)
- * can be selected. According to the MPC5200 user's manual, the oscillator
- * clock is the better choice as it has less jitter but due to a hardware
- * bug, it can not be selected for the old MPC5200 Rev. A chips.
- */
-
-static unsigned int __devinit mpc52xx_can_clock_freq(struct of_device *of,
- int clock_src)
-{
- unsigned int pvr;
-
- pvr = mfspr(SPRN_PVR);
-
- if (clock_src == MSCAN_CLKSRC_BUS || pvr == 0x80822011)
- return mpc5xxx_get_bus_frequency(of->node);
-
- return mpc52xx_can_xtal_freq(of);
-}
-
static int __devinit mpc5xxx_can_probe(struct of_device *ofdev,
const struct of_device_id *id)
{
--
1.6.3.3
^ permalink raw reply related
* [PATCH 06/11] net/can/mscan: drop assignment in while-construct
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
As suggested by Wolfgang Grandegger.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/can/mscan/mscan.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index 76e413e..20d1991 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -379,8 +379,10 @@ static int mscan_rx_poll(struct napi_struct *napi, int quota)
struct can_frame *frame;
u8 canrflg;
- while (npackets < quota && ((canrflg = in_8(®s->canrflg)) &
- (MSCAN_RXF | MSCAN_ERR_IF))) {
+ while (npackets < quota) {
+ canrflg = in_8(®s->canrflg);
+ if (!(canrflg & (MSCAN_RXF | MSCAN_ERR_IF)))
+ break;
skb = alloc_can_skb(dev, &frame);
if (!skb) {
--
1.6.3.3
^ permalink raw reply related
* [PATCH 05/11] net/can/mscan: fix function annotations
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
- use extern where apropriate
- don't export symbols
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/can/mscan/mscan.c | 3 ---
drivers/net/can/mscan/mscan.h | 2 +-
2 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index ca8b556..76e413e 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -611,7 +611,6 @@ int register_mscandev(struct net_device *dev, int clock_src)
return register_candev(dev);
}
-EXPORT_SYMBOL_GPL(register_mscandev);
void unregister_mscandev(struct net_device *dev)
{
@@ -621,7 +620,6 @@ void unregister_mscandev(struct net_device *dev)
clrbits8(®s->canctl1, MSCAN_CANE);
unregister_candev(dev);
}
-EXPORT_SYMBOL_GPL(unregister_mscandev);
struct net_device *alloc_mscandev(void)
{
@@ -651,7 +649,6 @@ struct net_device *alloc_mscandev(void)
return dev;
}
-EXPORT_SYMBOL_GPL(alloc_mscandev);
MODULE_AUTHOR("Andrey Volkov <avolkov@varma-el.com>");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/can/mscan/mscan.h b/drivers/net/can/mscan/mscan.h
index 76a8abf..2018000 100644
--- a/drivers/net/can/mscan/mscan.h
+++ b/drivers/net/can/mscan/mscan.h
@@ -279,7 +279,7 @@ struct mscan_priv {
struct napi_struct napi;
};
-struct net_device *alloc_mscandev(void);
+extern struct net_device *alloc_mscandev(void);
/*
* clock_src:
* 1 = The MSCAN clock source is the onchip Bus Clock.
--
1.6.3.3
^ permalink raw reply related
* [PATCH 04/11] net/can/mscan: use {clr|set}bits8 macros
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/can/mscan/mscan.c | 19 +++++++------------
1 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index 839b471..ca8b556 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -78,8 +78,7 @@ static int mscan_set_mode(struct net_device *dev, u8 mode)
canctl1 = in_8(®s->canctl1);
if ((mode & MSCAN_SLPRQ) && !(canctl1 & MSCAN_SLPAK)) {
- out_8(®s->canctl0,
- in_8(®s->canctl0) | MSCAN_SLPRQ);
+ setbits8(®s->canctl0, MSCAN_SLPRQ);
for (i = 0; i < MSCAN_SET_MODE_RETRIES; i++) {
if (in_8(®s->canctl1) & MSCAN_SLPAK)
break;
@@ -105,8 +104,7 @@ static int mscan_set_mode(struct net_device *dev, u8 mode)
}
if ((mode & MSCAN_INITRQ) && !(canctl1 & MSCAN_INITAK)) {
- out_8(®s->canctl0,
- in_8(®s->canctl0) | MSCAN_INITRQ);
+ setbits8(®s->canctl0, MSCAN_INITRQ);
for (i = 0; i < MSCAN_SET_MODE_RETRIES; i++) {
if (in_8(®s->canctl1) & MSCAN_INITAK)
break;
@@ -118,14 +116,12 @@ static int mscan_set_mode(struct net_device *dev, u8 mode)
priv->can.state = CAN_STATE_STOPPED;
if (mode & MSCAN_CSWAI)
- out_8(®s->canctl0,
- in_8(®s->canctl0) | MSCAN_CSWAI);
+ setbits8(®s->canctl0, MSCAN_CSWAI);
} else {
canctl1 = in_8(®s->canctl1);
if (canctl1 & (MSCAN_SLPAK | MSCAN_INITAK)) {
- out_8(®s->canctl0, in_8(®s->canctl0) &
- ~(MSCAN_SLPRQ | MSCAN_INITRQ));
+ clrbits8(®s->canctl0, MSCAN_SLPRQ | MSCAN_INITRQ);
for (i = 0; i < MSCAN_SET_MODE_RETRIES; i++) {
canctl1 = in_8(®s->canctl1);
if (!(canctl1 & (MSCAN_INITAK | MSCAN_SLPAK)))
@@ -359,8 +355,7 @@ static void mscan_get_err_frame(struct net_device *dev, struct can_frame *frame,
*/
out_8(®s->cantier, 0);
out_8(®s->canrier, 0);
- out_8(®s->canctl0, in_8(®s->canctl0) |
- MSCAN_SLPRQ | MSCAN_INITRQ);
+ setbits8(®s->canctl0, MSCAN_SLPRQ | MSCAN_INITRQ);
can_bus_off(dev);
break;
default:
@@ -548,7 +543,7 @@ static int mscan_open(struct net_device *dev)
priv->open_time = jiffies;
- out_8(®s->canctl1, in_8(®s->canctl1) & ~MSCAN_LISTEN);
+ clrbits8(®s->canctl1, MSCAN_LISTEN);
ret = mscan_start(dev);
if (ret)
@@ -623,7 +618,7 @@ void unregister_mscandev(struct net_device *dev)
struct mscan_priv *priv = netdev_priv(dev);
struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
mscan_set_mode(dev, MSCAN_INIT_MODE);
- out_8(®s->canctl1, in_8(®s->canctl1) & ~MSCAN_CANE);
+ clrbits8(®s->canctl1, MSCAN_CANE);
unregister_candev(dev);
}
EXPORT_SYMBOL_GPL(unregister_mscandev);
--
1.6.3.3
^ permalink raw reply related
* [PATCH 03/11] net/can/mscan: drop support for CAN_MODE_{SLEEP|STOP}
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
The upper layer does not support it yet.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/can/mscan/mscan.c | 8 --------
1 files changed, 0 insertions(+), 8 deletions(-)
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index 6394de8..839b471 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -487,14 +487,6 @@ static int mscan_do_set_mode(struct net_device *dev, enum can_mode mode)
return -EINVAL;
switch (mode) {
- case CAN_MODE_SLEEP:
- case CAN_MODE_STOP:
- netif_stop_queue(dev);
- mscan_set_mode(dev,
- (mode ==
- CAN_MODE_STOP) ? MSCAN_INIT_MODE :
- MSCAN_SLEEP_MODE);
- break;
case CAN_MODE_START:
if (priv->can.state <= CAN_STATE_BUS_OFF)
mscan_set_mode(dev, MSCAN_INIT_MODE);
--
1.6.3.3
^ permalink raw reply related
* [PATCH 02/11] net/can/mscan: trivial fixes
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
- remove whitespaces
- use ! and ?: when apropriate
- make braces consistent
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/can/mscan/mpc52xx_can.c | 16 +++++-----------
drivers/net/can/mscan/mscan.c | 25 +++++++++++++------------
2 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/drivers/net/can/mscan/mpc52xx_can.c b/drivers/net/can/mscan/mpc52xx_can.c
index 4707a82..34ae2ba 100644
--- a/drivers/net/can/mscan/mpc52xx_can.c
+++ b/drivers/net/can/mscan/mpc52xx_can.c
@@ -34,7 +34,6 @@
#include "mscan.h"
-
#define DRV_NAME "mpc5xxx_can"
static struct of_device_id mpc52xx_cdm_ids[] __devinitdata = {
@@ -71,15 +70,10 @@ static unsigned int __devinit mpc52xx_can_xtal_freq(struct of_device *of)
if (in_8(&cdm->ipb_clk_sel) & 0x1)
freq *= 2;
- val = in_be32(&cdm->rstcfg);
- if (val & (1 << 5))
- freq *= 8;
- else
- freq *= 4;
- if (val & (1 << 6))
- freq /= 12;
- else
- freq /= 16;
+ val = in_be32(&cdm->rstcfg);
+
+ freq *= (val & (1 << 5)) ? 8 : 4;
+ freq /= (val & (1 << 6)) ? 12 : 16;
iounmap(cdm);
@@ -222,7 +216,7 @@ static int mpc5xxx_can_resume(struct of_device *ofdev)
struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
regs->canctl0 |= MSCAN_INITRQ;
- while ((regs->canctl1 & MSCAN_INITAK) == 0)
+ while (!(regs->canctl1 & MSCAN_INITAK))
udelay(10);
regs->canctl1 = saved_regs.canctl1;
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index 2539ebe..6394de8 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -69,7 +69,6 @@ static int mscan_set_mode(struct net_device *dev, u8 mode)
u8 canctl1;
if (mode != MSCAN_NORMAL_MODE) {
-
if (priv->tx_active) {
/* Abort transfers before going to sleep */#
out_8(®s->cantarq, priv->tx_active);
@@ -78,7 +77,7 @@ static int mscan_set_mode(struct net_device *dev, u8 mode)
}
canctl1 = in_8(®s->canctl1);
- if ((mode & MSCAN_SLPRQ) && (canctl1 & MSCAN_SLPAK) == 0) {
+ if ((mode & MSCAN_SLPRQ) && !(canctl1 & MSCAN_SLPAK)) {
out_8(®s->canctl0,
in_8(®s->canctl0) | MSCAN_SLPRQ);
for (i = 0; i < MSCAN_SET_MODE_RETRIES; i++) {
@@ -105,7 +104,7 @@ static int mscan_set_mode(struct net_device *dev, u8 mode)
priv->can.state = CAN_STATE_SLEEPING;
}
- if ((mode & MSCAN_INITRQ) && (canctl1 & MSCAN_INITAK) == 0) {
+ if ((mode & MSCAN_INITRQ) && !(canctl1 & MSCAN_INITAK)) {
out_8(®s->canctl0,
in_8(®s->canctl0) | MSCAN_INITRQ);
for (i = 0; i < MSCAN_SET_MODE_RETRIES; i++) {
@@ -233,7 +232,8 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (!rtr) {
void __iomem *data = ®s->tx.dsr1_0;
- u16 *payload = (u16 *) frame->data;
+ u16 *payload = (u16 *)frame->data;
+
/* It is safe to write into dsr[dlc+1] */
for (i = 0; i < (frame->can_dlc + 1) / 2; i++) {
out_be16(data, *payload++);
@@ -300,7 +300,8 @@ static void mscan_get_rx_frame(struct net_device *dev, struct can_frame *frame)
if (!(frame->can_id & CAN_RTR_FLAG)) {
void __iomem *data = ®s->rx.dsr1_0;
- u16 *payload = (u16 *) frame->data;
+ u16 *payload = (u16 *)frame->data;
+
for (i = 0; i < (frame->can_dlc + 1) / 2; i++) {
*payload++ = in_be16(data);
data += 2 + _MSCAN_RESERVED_DSR_SIZE;
@@ -326,8 +327,9 @@ static void mscan_get_err_frame(struct net_device *dev, struct can_frame *frame,
frame->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
stats->rx_over_errors++;
stats->rx_errors++;
- } else
+ } else {
frame->data[1] = 0;
+ }
old_state = check_set_state(dev, canrflg);
/* State changed */
@@ -339,7 +341,6 @@ static void mscan_get_err_frame(struct net_device *dev, struct can_frame *frame,
if ((priv->shadow_statflg & MSCAN_RSTAT_MSK) <
(canrflg & MSCAN_RSTAT_MSK))
frame->data[1] |= CAN_ERR_CRTL_RX_WARNING;
-
if ((priv->shadow_statflg & MSCAN_TSTAT_MSK) <
(canrflg & MSCAN_TSTAT_MSK))
frame->data[1] |= CAN_ERR_CRTL_TX_WARNING;
@@ -397,7 +398,7 @@ static int mscan_rx_poll(struct napi_struct *napi, int quota)
if (canrflg & MSCAN_RXF)
mscan_get_rx_frame(dev, frame);
- else if (canrflg & MSCAN_ERR_IF)
+ else if (canrflg & MSCAN_ERR_IF)
mscan_get_err_frame(dev, frame, canrflg);
stats->rx_packets++;
@@ -429,7 +430,6 @@ static irqreturn_t mscan_isr(int irq, void *dev_id)
cantflg = in_8(®s->cantflg) & cantier;
if (cantier && cantflg) {
-
struct list_head *tmp, *pos;
list_for_each_safe(pos, tmp, &priv->tx_head) {
@@ -452,8 +452,9 @@ static irqreturn_t mscan_isr(int irq, void *dev_id)
clear_bit(F_TX_WAIT_ALL, &priv->flags);
clear_bit(F_TX_PROGRESS, &priv->flags);
priv->cur_pri = 0;
- } else
+ } else {
dev->trans_start = jiffies;
+ }
if (!test_bit(F_TX_WAIT_ALL, &priv->flags))
netif_wake_queue(dev);
@@ -470,15 +471,15 @@ static irqreturn_t mscan_isr(int irq, void *dev_id)
out_8(®s->canrier, 0);
napi_schedule(&priv->napi);
ret = IRQ_HANDLED;
- } else
+ } else {
clear_bit(F_RX_PROGRESS, &priv->flags);
+ }
}
return ret;
}
static int mscan_do_set_mode(struct net_device *dev, enum can_mode mode)
{
-
struct mscan_priv *priv = netdev_priv(dev);
int ret = 0;
--
1.6.3.3
^ permalink raw reply related
* [PATCH 01/11] net/can/mscan: move defines into .h file
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
In-Reply-To: <1258412274-14686-1-git-send-email-w.sang@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/can/mscan/mscan.c | 29 -----------------------------
drivers/net/can/mscan/mscan.h | 29 +++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c
index 49542ca..2539ebe 100644
--- a/drivers/net/can/mscan/mscan.c
+++ b/drivers/net/can/mscan/mscan.c
@@ -35,31 +35,6 @@
#include "mscan.h"
-#define MSCAN_NORMAL_MODE 0
-#define MSCAN_SLEEP_MODE MSCAN_SLPRQ
-#define MSCAN_INIT_MODE (MSCAN_INITRQ | MSCAN_SLPRQ)
-#define MSCAN_POWEROFF_MODE (MSCAN_CSWAI | MSCAN_SLPRQ)
-#define MSCAN_SET_MODE_RETRIES 255
-#define MSCAN_ECHO_SKB_MAX 3
-
-#define BTR0_BRP_MASK 0x3f
-#define BTR0_SJW_SHIFT 6
-#define BTR0_SJW_MASK (0x3 << BTR0_SJW_SHIFT)
-
-#define BTR1_TSEG1_MASK 0xf
-#define BTR1_TSEG2_SHIFT 4
-#define BTR1_TSEG2_MASK (0x7 << BTR1_TSEG2_SHIFT)
-#define BTR1_SAM_SHIFT 7
-
-#define BTR0_SET_BRP(brp) (((brp) - 1) & BTR0_BRP_MASK)
-#define BTR0_SET_SJW(sjw) ((((sjw) - 1) << BTR0_SJW_SHIFT) & \
- BTR0_SJW_MASK)
-
-#define BTR1_SET_TSEG1(tseg1) (((tseg1) - 1) & BTR1_TSEG1_MASK)
-#define BTR1_SET_TSEG2(tseg2) ((((tseg2) - 1) << BTR1_TSEG2_SHIFT) & \
- BTR1_TSEG2_MASK)
-#define BTR1_SET_SAM(sam) ((sam) ? 1 << BTR1_SAM_SHIFT : 0)
-
static struct can_bittiming_const mscan_bittiming_const = {
.name = "mscan",
.tseg1_min = 4,
@@ -78,10 +53,6 @@ struct mscan_state {
u8 cantier;
};
-#define F_RX_PROGRESS 0
-#define F_TX_PROGRESS 1
-#define F_TX_WAIT_ALL 2
-
static enum can_state state_map[] = {
CAN_STATE_ERROR_ACTIVE,
CAN_STATE_ERROR_WARNING,
diff --git a/drivers/net/can/mscan/mscan.h b/drivers/net/can/mscan/mscan.h
index 57820f5..76a8abf 100644
--- a/drivers/net/can/mscan/mscan.h
+++ b/drivers/net/can/mscan/mscan.h
@@ -226,6 +226,35 @@ struct mscan_regs {
#undef _MSCAN_RESERVED_
#define MSCAN_REGION sizeof(struct mscan)
+#define MSCAN_NORMAL_MODE 0
+#define MSCAN_SLEEP_MODE MSCAN_SLPRQ
+#define MSCAN_INIT_MODE (MSCAN_INITRQ | MSCAN_SLPRQ)
+#define MSCAN_POWEROFF_MODE (MSCAN_CSWAI | MSCAN_SLPRQ)
+#define MSCAN_SET_MODE_RETRIES 255
+#define MSCAN_ECHO_SKB_MAX 3
+
+#define BTR0_BRP_MASK 0x3f
+#define BTR0_SJW_SHIFT 6
+#define BTR0_SJW_MASK (0x3 << BTR0_SJW_SHIFT)
+
+#define BTR1_TSEG1_MASK 0xf
+#define BTR1_TSEG2_SHIFT 4
+#define BTR1_TSEG2_MASK (0x7 << BTR1_TSEG2_SHIFT)
+#define BTR1_SAM_SHIFT 7
+
+#define BTR0_SET_BRP(brp) (((brp) - 1) & BTR0_BRP_MASK)
+#define BTR0_SET_SJW(sjw) ((((sjw) - 1) << BTR0_SJW_SHIFT) & \
+ BTR0_SJW_MASK)
+
+#define BTR1_SET_TSEG1(tseg1) (((tseg1) - 1) & BTR1_TSEG1_MASK)
+#define BTR1_SET_TSEG2(tseg2) ((((tseg2) - 1) << BTR1_TSEG2_SHIFT) & \
+ BTR1_TSEG2_MASK)
+#define BTR1_SET_SAM(sam) ((sam) ? 1 << BTR1_SAM_SHIFT : 0)
+
+#define F_RX_PROGRESS 0
+#define F_TX_PROGRESS 1
+#define F_TX_WAIT_ALL 2
+
#define TX_QUEUE_SIZE 3
struct tx_queue_entry {
--
1.6.3.3
^ permalink raw reply related
* updates to the mscan-driver in net-next
From: Wolfram Sang @ 2009-11-16 22:57 UTC (permalink / raw)
To: netdev; +Cc: socketcan-core, linuxppc-dev, David Miller
Hello,
here are the patches which fix the issues for the mscan & mpc52xx_can drivers
raised by Wolfgang Grandegger and Grant Likely. They are based on the initial
version of the drivers I sent a few days ago. Devicetree-discuss has been added
for the property changes. I will also update my branch on pengutronix.de
tomorrow, I seem to have issues when trying that from home :(^
Regards,
Wolfram
Wolfram Sang (11):
net/can/mscan: move defines into .h file
net/can/mscan: trivial fixes
net/can/mscan: drop support for CAN_MODE_{SLEEP|STOP}
net/can/mscan: use {clr|set}bits8 macros
net/can/mscan: fix function annotations
net/can/mscan: drop assignment in while-construct
net/can/mpc52xx_can: refactor clock-get routine
net/can/mpc52xx_can: improve properties and their description
net/can/mscan: replace hardcoded values with defines
net/can/mscan: add error path to mscan_open()
net/can/mscan: improve build
Documentation/powerpc/dts-bindings/fsl/mpc5200.txt | 9 +-
drivers/net/can/Kconfig | 19 +---
drivers/net/can/mscan/Kconfig | 23 ++++
drivers/net/can/mscan/Makefile | 4 +-
.../net/can/mscan/{mpc52xx_can.c => mpc5xxx_can.c} | 64 ++++-------
drivers/net/can/mscan/mscan.c | 121 +++++++------------
drivers/net/can/mscan/mscan.h | 36 ++++++-
7 files changed, 133 insertions(+), 143 deletions(-)
create mode 100644 drivers/net/can/mscan/Kconfig
rename drivers/net/can/mscan/{mpc52xx_can.c => mpc5xxx_can.c} (90%)
^ permalink raw reply
* Re: [PATCH 00/10] Fix 8xx MMU/TLB
From: Joakim Tjernlund @ 2009-11-16 22:53 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev@ozlabs.org, Rex Feany
In-Reply-To: <20091116212741.GA10968@loki.buserror.net>
Scott Wood <scottwood@freescale.com> wrote on 16/11/2009 22:27:41:
>
> On Mon, Nov 16, 2009 at 03:00:09PM -0600, Scott Wood wrote:
> > On Sun, Nov 15, 2009 at 06:09:27PM +0100, Joakim Tjernlund wrote:
> > > [I used the wrong branch, this will hopefully not conflict]
> > >
> > > This is hopfully the last iteration of the series.
> > > Rex & Scott, please test and signoff.
> > > Changes since last version:
> > > - Added mandatory pinning of iTLB
> > > - Added "DTLB Miss cleanup"
> >
> > I still get the EFAULTs.
umm, this worked before this series with your own
version, right?
Did I screw up with the "DTLB Miss cleanup"?
Does the self modifying code version work any better?
>
> This snippet of strace is particularly interesting:
>
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
> 0x30020000
> read(0, 0x30020000, 1024) = -1 EFAULT (Bad address)
I remember Rex saw something similar?
>
> Or this:
>
> brk(0x10036000) = 0x10036000
> fstat64(1, {st_mode=S_IFCHR|0660, st_rdev=makedev(5, 1), ...}) = 0
> open("/etc/mtab", O_RDONLY|O_LARGEFILE) = 3
> fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
> read(3, 0x10016000, 4096) = -1 EFAULT (Bad address)
>
> It seems that the failures are related to reading from /proc (/etc/mtab is
> linked to /proc/mounts), though some /proc reads work
> (/proc/self/oom_score). I also see the uname syscall failing in some apps
> (but not in the uname app itself, oddly), especially /proc-related apps such
> as ps and top, though they're not actually accessing /proc with this call:
>
> uname(0xffef7d0) = -1 EFAULT (Bad address)
>
> -Scott
>
>
^ permalink raw reply
* Re: [PATCH 00/10] Fix 8xx MMU/TLB
From: Scott Wood @ 2009-11-16 21:27 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: linuxppc-dev@ozlabs.org, Rex Feany
In-Reply-To: <20091116210009.GA5113@loki.buserror.net>
On Mon, Nov 16, 2009 at 03:00:09PM -0600, Scott Wood wrote:
> On Sun, Nov 15, 2009 at 06:09:27PM +0100, Joakim Tjernlund wrote:
> > [I used the wrong branch, this will hopefully not conflict]
> >
> > This is hopfully the last iteration of the series.
> > Rex & Scott, please test and signoff.
> > Changes since last version:
> > - Added mandatory pinning of iTLB
> > - Added "DTLB Miss cleanup"
>
> I still get the EFAULTs.
This snippet of strace is particularly interesting:
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x30020000
read(0, 0x30020000, 1024) = -1 EFAULT (Bad address)
Or this:
brk(0x10036000) = 0x10036000
fstat64(1, {st_mode=S_IFCHR|0660, st_rdev=makedev(5, 1), ...}) = 0
open("/etc/mtab", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, 0x10016000, 4096) = -1 EFAULT (Bad address)
It seems that the failures are related to reading from /proc (/etc/mtab is
linked to /proc/mounts), though some /proc reads work
(/proc/self/oom_score). I also see the uname syscall failing in some apps
(but not in the uname app itself, oddly), especially /proc-related apps such
as ps and top, though they're not actually accessing /proc with this call:
uname(0xffef7d0) = -1 EFAULT (Bad address)
-Scott
^ permalink raw reply
* Re: [PATCH 00/10] Fix 8xx MMU/TLB
From: Scott Wood @ 2009-11-16 21:00 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: linuxppc-dev@ozlabs.org, Rex Feany
In-Reply-To: <1258304977-11760-1-git-send-email-Joakim.Tjernlund@transmode.se>
On Sun, Nov 15, 2009 at 06:09:27PM +0100, Joakim Tjernlund wrote:
> [I used the wrong branch, this will hopefully not conflict]
>
> This is hopfully the last iteration of the series.
> Rex & Scott, please test and signoff.
> Changes since last version:
> - Added mandatory pinning of iTLB
> - Added "DTLB Miss cleanup"
I still get the EFAULTs.
-Scott
^ permalink raw reply
* Re: [PATCH 3/4] mpc8349emitx: add OF descriptions of LocalBus devices
From: Dmitry Eremin-Solenikov @ 2009-11-16 20:51 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
In-Reply-To: <20091116193627.GA15505@b07421-ec1.am.freescale.net>
Describe all LocalBus chipselects on MPC8349E-MITX board. Also add flash
bindings.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
arch/powerpc/boot/dts/mpc8349emitx.dts | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/boot/dts/mpc8349emitx.dts b/arch/powerpc/boot/dts/mpc8349emitx.dts
index 0fb78b2..346d1ba 100644
--- a/arch/powerpc/boot/dts/mpc8349emitx.dts
+++ b/arch/powerpc/boot/dts/mpc8349emitx.dts
@@ -374,7 +374,26 @@
compatible = "fsl,mpc8349e-localbus",
"fsl,pq2pro-localbus";
reg = <0xe0005000 0xd8>;
- ranges = <0x3 0x0 0xf0000000 0x210>;
+ ranges = <0x0 0x0 0xfe000000 0x1000000 /* flash */
+ 0x1 0x0 0xf8000000 0x20000 /* VSC 7385 */
+ 0x2 0x0 0xf9000000 0x200000 /* exp slot */
+ 0x3 0x0 0xf0000000 0x210>; /* CF slot */
+
+ flash@0,0 {
+ compatible = "cfi-flash";
+ reg = <0x0 0x0 0x800000>;
+ bank-width = <2>;
+ device-width = <1>;
+ };
+
+ flash@0,800000 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "cfi-flash";
+ reg = <0x0 0x800000 0x800000>;
+ bank-width = <2>;
+ device-width = <1>;
+ };
pata@3,0 {
compatible = "fsl,mpc8349emitx-pata", "ata-generic";
--
1.6.5
--
With best wishes
Dmitry
^ permalink raw reply related
* Re: [PATCH 3/4] mpc8349emitx: add OF descriptions of LocalBus devices
From: Scott Wood @ 2009-11-16 19:36 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: linuxppc-dev
In-Reply-To: <1258379934-32352-4-git-send-email-dbaryshkov@gmail.com>
On Mon, Nov 16, 2009 at 04:58:53PM +0300, Dmitry Eremin-Solenikov wrote:
> + flash@0,1 {
> + #address-cells = <1>;
> + #size-cells = <1>;
> + compatible = "cfi-flash";
> + reg = <0x0 0x800000 0x800000>;
> + bank-width = <2>;
> + device-width = <1>;
> + };
Should be "flash@0,800000".
-Scott
^ permalink raw reply
* Re: [PATCH] net/can: add driver for mscan family & mpc52xx_mscan
From: Wolfram Sang @ 2009-11-16 18:44 UTC (permalink / raw)
To: Grant Likely; +Cc: socketcan-core, netdev, David Miller, linuxppc-dev
In-Reply-To: <fa686aa40911130939x54ac53f9x173a875a5a4435d3@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 506 bytes --]
Hi Grant,
Wolfgang commented on some points already, I will pick up the other remarks,
just one question:
> > + clk_src = of_get_property(np, "fsl,mscan-clk-src", NULL);
> > + if (clk_src && strcmp(clk_src, "ip") == 0)
>
> Should protect against non-null. strncmp() maybe?
"ip" is null-terminated, or what do you mean?
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: spi_mpc8xxx.c: chip select polarity problem
From: Anton Vorontsov @ 2009-11-16 18:00 UTC (permalink / raw)
To: Torsten Fleischer; +Cc: linuxppc-dev
In-Reply-To: <20091116171037.GA26163@oksana.dev.rtsoft.ru>
On Mon, Nov 16, 2009 at 08:10:37PM +0300, Anton Vorontsov wrote:
[...]
> > I also tried to set alow_flags[x] = 0 for active low. In this case the
> > transfer works, but the initial value for the CS is wrong (Low instead of
> > High).
>
> So it might be better to fix up initial value in the platform code?
Oh, we actually cannot, because the driver calls
gpio_direction_output().
And since we don't know the mode prior to SPI device's driver
probe() finished, we'll have to set up an initial state in the
first SPI transfer. I.e. something like this:
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
index 0fd0ec4..3b95382 100644
--- a/drivers/spi/spi_mpc8xxx.c
+++ b/drivers/spi/spi_mpc8xxx.c
@@ -114,6 +114,7 @@ struct spi_mpc8xxx_cs {
u32 rx_shift; /* RX data reg shift when in qe mode */
u32 tx_shift; /* TX data reg shift when in qe mode */
u32 hw_mode; /* Holds HW mode register settings */
+ int initialized;
};
static inline void mpc8xxx_spi_write_reg(__be32 __iomem *reg, u32 val)
@@ -507,11 +508,17 @@ static int mpc8xxx_spi_transfer(struct spi_device *spi,
struct spi_message *m)
{
struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
+ struct spi_mpc8xxx_cs *cs = spi->controller_state;
unsigned long flags;
m->actual_length = 0;
m->status = -EINPROGRESS;
+ if (cs && !cs->initialized) {
+ mpc8xxx_spi_chipselect(spi, BITBANG_CS_INACTIVE);
+ cs->initialized = 1;
+ }
+
spin_lock_irqsave(&mpc8xxx_spi->lock, flags);
list_add_tail(&m->queue, &mpc8xxx_spi->queue);
queue_work(mpc8xxx_spi->workqueue, &mpc8xxx_spi->work);
^ permalink raw reply related
* Re: [PATCH 1/1] ata/sata_sil24: MSI support, disabled by default
From: Grant Grundler @ 2009-11-16 17:37 UTC (permalink / raw)
To: Vivek Mahajan; +Cc: linux-ide, linuxppc-dev
In-Reply-To: <1258352362-11231-1-git-send-email-vivek.mahajan@freescale.com>
On Sun, Nov 15, 2009 at 10:19 PM, Vivek Mahajan
<vivek.mahajan@freescale.com> wrote:
> The following patch adds MSI support. Some platforms
> may have broken MSI, so those are defaulted to use
> legacy PCI interrupts.
>
> Signed-off-by: Vivek Mahajan <vivek.mahajan@freescale.com>
> ---
> =C2=A0drivers/ata/sata_sil24.c | =C2=A0 =C2=A09 +++++++++
> =C2=A01 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
> index e6946fc..1370df6 100644
> --- a/drivers/ata/sata_sil24.c
> +++ b/drivers/ata/sata_sil24.c
> @@ -417,6 +417,10 @@ static struct ata_port_operations sil24_ops =3D {
> =C2=A0#endif
> =C2=A0};
>
> +static int sata_sil24_msi; =C2=A0 =C2=A0/* Disable MSI */
> +module_param_named(msi, sata_sil24_msi, bool, S_IRUGO);
> +MODULE_PARM_DESC(msi, "Enable MSI (Default: false)");
Vivek,
Do we even still need the parameter? I'm thinking either MSI works
with a chipset
or it doesn't. The kernel has globals to "know" which state is true.
If the parameter is needed, when this driver is compiled into the kernel, h=
ow
is "msi" parameter specified?
I think the parameter needs to be documented and fit in with other
"msi" parameters.
See "nomsi" in Documentation/kernel-parameters.txt.
If you want to keep this module parameter, can I suggest calling the
exported parameter "sata_sil24_msi"?
I'm not able to test this since the chipset I have sata_sil24 devices
plugged into don't support MSI (older AMD/Nvidia chipset). :(
> +
> =C2=A0/*
> =C2=A0* Use bits 30-31 of port_flags to encode available port numbers.
> =C2=A0* Current maxium is 4.
> @@ -1340,6 +1344,11 @@ static int sil24_init_one(struct pci_dev *pdev, co=
nst struct pci_device_id *ent)
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0sil24_init_controller(host);
>
> + =C2=A0 =C2=A0 =C2=A0 if (sata_sil24_msi && !!pci_msi_enable(pdev)) {
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dev_printk(KERN_INFO, =
&pdev->dev, "Using MSI\n");
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pci_intx(pdev, 0);
pci_intx() isn't documented in MSI-HOWTO.txt - because it's already called=
:
pci_msi_enable() -> pci_msi_enable_block() -> msi_capability_init()
-> pci_intx_for_msi(dev, 0) -> pci_intx(pdev, 0);
(thanks to willy (Mathew Wilcox) for pointing me at
msi_capability_init() - I overlooked it)
Please add "Reviewed-by: Grant Grundler <grundler@google.com>" once the
variable name is changed and the pci_intx() call is removed.
cheers,
grant
> + =C2=A0 =C2=A0 =C2=A0 }
> +
> =C2=A0 =C2=A0 =C2=A0 =C2=A0pci_set_master(pdev);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0return ata_host_activate(host, pdev->irq, sil2=
4_interrupt, IRQF_SHARED,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &sil24_sht);
> --
> 1.5.6.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at =C2=A0http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* [PATCH] POWERPC 4xx: Fix PCI in AMCC 440EP Yosemite DTS
From: Curtis Wald @ 2009-11-16 17:36 UTC (permalink / raw)
To: jwboyer, mporter; +Cc: linuxppc-dev
Yosemite.dts stanza for PCI was copied from Bamboo which has four PCI
slots; Yosemite only has one PCI slot which is mapped to
IDSEL 12, ADDR 22, IRQ2 Vector 25, INTA.
Signed-off-by: Curtis Wald <cwald@watchguardvideo.com>
---
arch/powerpc/boot/dts/yosemite.dts | 17 +++++------------
1 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/arch/powerpc/boot/dts/yosemite.dts
b/arch/powerpc/boot/dts/yosemite.dts
index 1fa3cb4..8328be5 100644
--- a/arch/powerpc/boot/dts/yosemite.dts
+++ b/arch/powerpc/boot/dts/yosemite.dts
@@ -276,26 +276,19 @@
* later cannot be changed. Chip supports a
second
* IO range but we don't use it for now
*/
+
+ /* u32 u64
u64 u64 */
+ /* pci_space pci_addr
cpu_addr size */
ranges =3D <0x02000000 0x00000000 0xa0000000
0x00000000 0xa0000000 0x00000000 0x20000000
0x01000000 0x00000000 0x00000000
0x00000000 0xe8000000 0x00000000 0x00010000>;
=20
/* Inbound 2GB range starting at 0 */
dma-ranges =3D <0x42000000 0x0 0x0 0x0 0x0 0x0
0x80000000>;
=20
- /* Bamboo has all 4 IRQ pins tied together per
slot */
interrupt-map-mask =3D <0xf800 0x0 0x0 0x0>;
interrupt-map =3D <
- /* IDSEL 1 */
- 0x800 0x0 0x0 0x0 &UIC0 0x1c 0x8
-
- /* IDSEL 2 */
- 0x1000 0x0 0x0 0x0 &UIC0 0x1b 0x8
-
- /* IDSEL 3 */
- 0x1800 0x0 0x0 0x0 &UIC0 0x1a 0x8
-
- /* IDSEL 4 */
- 0x2000 0x0 0x0 0x0 &UIC0 0x19 0x8
+ /* IDSEL 12, ADDR 22, INTA, IRQ2 =3D
Vector 25, 0x19 */
+ 0x6000 0x0 0x0 0x0 &UIC0 0x19 0x8
>;
};
};
^ permalink raw reply related
* Re: spi_mpc8xxx.c: chip select polarity problem
From: Anton Vorontsov @ 2009-11-16 17:10 UTC (permalink / raw)
To: Torsten Fleischer; +Cc: linuxppc-dev
In-Reply-To: <200911161742.46663.to-fleischer@t-online.de>
On Mon, Nov 16, 2009 at 05:42:46PM +0100, Torsten Fleischer wrote:
> Hi all,
>
> I have 3 devices connected to the SPI bus of the MPC8313. For the Chip Select
> (CS) signals 3 GPIOs of the controller are used. But the driver uses the
> inverse polarity of the CS either during the initialization or at the transfer
> - depending on the setup of the flattened device tree.
>
> Here is what I discovered:
> The driver uses a polarity flag for each CS signal (the alow_flags array).
> These flags are set according to the 'gpios' property of the SPI node of the
> flattened device tree.
> Is it correct that alow_flags[x] = 1 means CSx is active low?
Either way should work. Though, now I tend to I think that
'spi-cs-high' is actually already encoded in the compatible
name. E.g. for device X we always know that the device assumes
CS to be active low, so it has no spi-cs-high.
How chip selects are wired to a device is another matter.
> During the initialization the driver sets the CS to the value of
> alow_flags[x]. I.e. CSx is High if alow_flags[x] = 1 and otherwise Low.
>
> The flags are used in the function mpc8xxx_spi_cs_control() to take care about
> the polarity when setting the appropriate GPIO pin. But the function
> mpc8xxx_spi_chipselect() that calls the mpc8xxx_spi_cs_control() takes also
> care about the polarity of the CS (bool pol = spi->mode & SPI_CS_HIGH).
>
> Lets assume alow_flags[x] = 1 and the property 'spi-cs-high' is not set for
> the SPI device. During initialization the driver sets the chip select signal
> 'x' to High (see of_mpc8xxx_spi_get_chipselects()). This is OK if the chip
> select is active low, because this disables the device on start-up. But during
> the transfer the chip select signal is High and after the transfer is
> completed the signal is set to Low. This is not the intended behavior for an
> active low chip select.
>
> I also tried to set alow_flags[x] = 0 for active low. In this case the
> transfer works, but the initial value for the CS is wrong (Low instead of
> High).
So it might be better to fix up initial value in the platform code?
> The problem seems to be that the polarity is taken into account twice (as
> described above).
Yep. So, today I'd suggest to not use spe-cs-high, even though
I was OK with it before.
> So what would be the better solution: removing the usage of the alow_flags in
> mpc8xxx_spi_cs_control() or the variable 'pol' in mpc8xxx_spi_chipselect()?
Neither. 'pol' is still needed. Don't mix device wiring and the
chip select type. Driver may play active-low/high games with
a device, some drivers pass or clear SPI_CS_HIGH flags by themselves
(e.g. mmc_spi.c), so device-tree don't have to have spi-cs-high
flag specified.
But the wire from a GPIO controller to a SPI device can be inverted,
so you'll have to account that too!
Thanks,
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox