LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/4] mpc8349emitx: add leds-gpio binding
From: Dmitry Eremin-Solenikov @ 2009-11-16 13:58 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev
In-Reply-To: <1258379934-32352-1-git-send-email-dbaryshkov@gmail.com>

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/boot/dts/mpc8349emitx.dts |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8349emitx.dts b/arch/powerpc/boot/dts/mpc8349emitx.dts
index 097950c..fb58a7c 100644
--- a/arch/powerpc/boot/dts/mpc8349emitx.dts
+++ b/arch/powerpc/boot/dts/mpc8349emitx.dts
@@ -318,6 +318,24 @@
 			reg = <0x700 0x100>;
 			device_type = "ipic";
 		};
+
+		gpio-leds {
+			compatible = "gpio-leds";
+
+			green {
+				label = "Green";
+				gpios = <&pcf1 0 1>;
+				linux,default-trigger = "heartbeat";
+			};
+
+			yellow {
+				label = "Yellow";
+				gpios = <&pcf1 1 1>;
+				/* linux,default-trigger = "heartbeat"; */
+				default-state = "on";
+			};
+		};
+
 	};
 
 	pci0: pci@e0008500 {
-- 
1.6.5

^ permalink raw reply related

* [Proposal] [PATCH] [RESEND] generic clock framework
From: Francesco VIRLINZI @ 2009-11-16 13:47 UTC (permalink / raw)
  To: Linux-sh, linux-embedded, linux-arm-kernel, linux-pm,
	linux-kernel, linuxppc-dev

Hi all

I'm Francesco and I work in STMicroelectronics

In the last ELC-E_2009 I spoke on a generic clock framework I'm working on
  (see 
http://tree.celinuxforum.org/CelfPubWiki/ELCEurope2009Presentations?action=AttachFile&do=view&target=ELC_E_2009_Generic_Clock_Framework.pdf). 


I wrote the gcf to manage both clocks the platform_devices during a 
clock operation.

The main features are:
  - it's integrated in the LDM
  - it tracks the clock-to-clock relationship
  - it tracks the clock-to-device relationship

  - it has sysfs interface
  - - the user can navigate the clock tree under /sys/clocks/...

  - it uses the linux API (<linux/clk.h>) with some extra functions (to 
register/unregister a clock
    and other utility functions as clk_for_each())

  - it involves the platform_device and the platform_driver in the clock 
propagation.
  - - basically each clock operation is managed as a transaction which 
evolves step by step.
  - - all the clock rates are evaluated (before the clk operation is 
actually done)
  - - each platform_device can check (before the clk operation is 
actually done) the clk environment
      it will have at the end of clock operation and if required it can 
reject the operation.
  - - each clock operation is actually executed only if all the 
platform_devices accept the operation it-self


Moreover a common clock framework could be used to avoid a lot of 
duplicated and/or similar code
  just a grep of 'EXPORT_SYMBOL\(clk_enable' under arch/arm finds 22 
entries.

The patch is based on a 2.6.30 kernel also if it has a preliminary 
integration with the PM_RUNTIME
  support.

It works on our st40 (an sh4 cpu based system) no test/porting was done 
on other platforms.

It would be mainly a starting point for a discussion and I'm available 
to extend/fix/share it.

Regards
  Francesco

^ permalink raw reply

* RE: [PATCH/RFC] Booting Xilinx ML510 board using SystemACE
From: Stephen Neuendorffer @ 2009-11-16 16:23 UTC (permalink / raw)
  To: Alon Ziv, linuxppc-dev; +Cc: John Linn
In-Reply-To: <8B957E110B62714A84290A01A597805F05CA0AA1@Exchange.discretix.com>


Alon,

There are at least two other ways that you might be able to reset a
board:
1) Internally through the ICAP device.
2) Through a GPIO connected externally to the reset logic.

Part of this is board specific, part of is it design specific.
Probably it would be best to have a mechanism in the device tree which
references the
reset mechanism?  In any event, you probably don't want a driver to
eplicitly reference the plaform code.  If you want to do it explicitly
like this, it would better to have the plaform code reference the driver
mechanism.  This would, to some extent, generalize to the device tree
case.

Steve
 =

> -----Original Message-----
> From: linuxppc-dev-bounces+stephen=3Dneuendorffer.name@lists.ozlabs.org
[mailto:linuxppc-dev-
> bounces+stephen=3Dneuendorffer.name@lists.ozlabs.org] On Behalf Of Alon
Ziv
> Sent: Sunday, November 15, 2009 1:34 AM
> To: linuxppc-dev
> Subject: [PATCH/RFC] Booting Xilinx ML510 board using SystemACE
> =

> I am using locally the attached (hackish) patch; could someone propose
a
> way to make it acceptable to mainline (or should I just keep this
> quiet)?
> =

> diff --git a/arch/powerpc/platforms/44x/virtex.c
> b/arch/powerpc/platforms/44x/virtex.c
> index cf96cca..749a330 100644
> --- a/arch/powerpc/platforms/44x/virtex.c
> +++ b/arch/powerpc/platforms/44x/virtex.c
> @@ -51,6 +51,16 @@ static int __init virtex_probe(void)
>  	return 1;
>  }
> =

> +void (*board_reset_system)(char *);
> +EXPORT_SYMBOL(board_reset_system);
> +
> +static void virtex_reset_system(char *cmd)
> +{
> +	if (board_reset_system)
> +		board_reset_system(cmd);
> +	ppc4xx_reset_system(cmd);
> +}
> +
>  define_machine(virtex) {
>  	.name			=3D "Xilinx Virtex440",
>  	.probe			=3D virtex_probe,
> @@ -58,5 +68,5 @@ define_machine(virtex) {
>  	.init_IRQ		=3D xilinx_intc_init_tree,
>  	.get_irq		=3D xilinx_intc_get_irq,
>  	.calibrate_decr		=3D generic_calibrate_decr,
> -	.restart		=3D ppc4xx_reset_system,
> +	.restart		=3D virtex_reset_system,
>  };
> diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
> index b20abe1..f3b4ab9 100644
> --- a/drivers/block/xsysace.c
> +++ b/drivers/block/xsysace.c
> @@ -950,6 +950,19 @@ static struct block_device_operations ace_fops =3D
{
>  	.getgeo =3D ace_getgeo,
>  };
> =

> +extern void (*board_reset_system)(char *);
> +static struct ace_device *the_ace_device;
> +
> +/*
--------------------------------------------------------------------
> + * Board reset using ACE (forced FPGA reconfigure)
> + */
> +static void ace_reset_system(char *cmd)
> +{
> +	printk(KERN_EMERG "ace_reset_system: attempting suicide\n");
> +	ace_out(the_ace_device, ACE_CTRL, ACE_CTRL_FORCECFGMODE |
> +		ACE_CTRL_CFGMODE | ACE_CTRL_CFGSTART | ACE_CTRL_CFGSEL);
> +}
> +
>  /*
--------------------------------------------------------------------
>   * SystemACE device setup/teardown code
>   */
> @@ -1040,6 +1053,9 @@ static int __devinit ace_setup(struct ace_device
> *ace)
>  	val |=3D ACE_CTRL_DATABUFRDYIRQ | ACE_CTRL_ERRORIRQ;
>  	ace_out(ace, ACE_CTRL, val);
> =

> +	board_reset_system =3D ace_reset_system;
> +	the_ace_device =3D ace;
> +
>  	/* Print the identification */
>  	dev_info(ace->dev, "Xilinx SystemACE revision %i.%i.%i\n",
>  		 (version >> 12) & 0xf, (version >> 8) & 0x0f, version &
> 0xff);
>
************************************************************************
**********************
> IMPORTANT: The contents of this email and any attachments are
confidential. They are intended for the
> named recipient(s) only.
> If you have received this email in error, please notify the system
manager or the sender immediately
> and do
> not disclose the contents to anyone or make copies thereof.
> =

> =

> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev


This email and any attachments are intended for the sole use of the named r=
ecipient(s) and contain(s) confidential information that may be proprietary=
, privileged or copyrighted under applicable law. If you are not the intend=
ed recipient, do not read, copy, or forward this email message or any attac=
hments. Delete this email message and any attachments immediately.

^ permalink raw reply

* spi_mpc8xxx.c: chip select polarity problem
From: Torsten Fleischer @ 2009-11-16 16:42 UTC (permalink / raw)
  To: linuxppc-dev

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?

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).

The problem seems to be that the polarity is taken into account twice (as 
described above).
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()?

Best Regards
Torsten Fleischer

^ permalink raw reply

* 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

* [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: [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

* 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] 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: [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 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 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 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: 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

* 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

* [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

* [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(&regs->cantarq, priv->tx_active);
@@ -78,7 +77,7 @@ static int mscan_set_mode(struct net_device *dev, u8 mode)
 		}
 
 		canctl1 = in_8(&regs->canctl1);
-		if ((mode & MSCAN_SLPRQ) && (canctl1 & MSCAN_SLPAK) == 0) {
+		if ((mode & MSCAN_SLPRQ) && !(canctl1 & MSCAN_SLPAK)) {
 			out_8(&regs->canctl0,
 			      in_8(&regs->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(&regs->canctl0,
 			      in_8(&regs->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 = &regs->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 = &regs->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(&regs->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(&regs->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 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 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(&regs->canctl1);
 		if ((mode & MSCAN_SLPRQ) && !(canctl1 & MSCAN_SLPAK)) {
-			out_8(&regs->canctl0,
-			      in_8(&regs->canctl0) | MSCAN_SLPRQ);
+			setbits8(&regs->canctl0, MSCAN_SLPRQ);
 			for (i = 0; i < MSCAN_SET_MODE_RETRIES; i++) {
 				if (in_8(&regs->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(&regs->canctl0,
-			      in_8(&regs->canctl0) | MSCAN_INITRQ);
+			setbits8(&regs->canctl0, MSCAN_INITRQ);
 			for (i = 0; i < MSCAN_SET_MODE_RETRIES; i++) {
 				if (in_8(&regs->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(&regs->canctl0,
-			      in_8(&regs->canctl0) | MSCAN_CSWAI);
+			setbits8(&regs->canctl0, MSCAN_CSWAI);
 
 	} else {
 		canctl1 = in_8(&regs->canctl1);
 		if (canctl1 & (MSCAN_SLPAK | MSCAN_INITAK)) {
-			out_8(&regs->canctl0, in_8(&regs->canctl0) &
-			      ~(MSCAN_SLPRQ | MSCAN_INITRQ));
+			clrbits8(&regs->canctl0, MSCAN_SLPRQ | MSCAN_INITRQ);
 			for (i = 0; i < MSCAN_SET_MODE_RETRIES; i++) {
 				canctl1 = in_8(&regs->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(&regs->cantier, 0);
 			out_8(&regs->canrier, 0);
-			out_8(&regs->canctl0, in_8(&regs->canctl0) |
-				MSCAN_SLPRQ | MSCAN_INITRQ);
+			setbits8(&regs->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(&regs->canctl1, in_8(&regs->canctl1) & ~MSCAN_LISTEN);
+	clrbits8(&regs->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(&regs->canctl1, in_8(&regs->canctl1) & ~MSCAN_CANE);
+	clrbits8(&regs->canctl1, MSCAN_CANE);
 	unregister_candev(dev);
 }
 EXPORT_SYMBOL_GPL(unregister_mscandev);
-- 
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(&regs->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 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(&regs->canrflg)) &
-				    (MSCAN_RXF | MSCAN_ERR_IF))) {
+	while (npackets < quota) {
+		canrflg = in_8(&regs->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 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 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 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(&regs->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(&regs->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 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


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox