Re: [PATCH 4/4] powerpc/85xx: TQM8548: Update DTS file for multi-chip support

2009-03-18 Thread Wolfgang Grandegger
Anton Vorontsov wrote:
 On Tue, Mar 17, 2009 at 10:12:22AM +0100, Wolfgang Grandegegr wrote:
 From: Wolfgang Grandegger w...@grandegger.com

 This patch adds multi-chip support for the Micron MT29F8G08FAB NAND
 flash memory on the TQM8548 modules.

 This patch should go through the powerpc/85xx channel.

 Signed-off-by: Wolfgang Grandegger w...@grandegger.com
 ---
  arch/powerpc/boot/dts/tqm8548.dts |5 +
  1 files changed, 5 insertions(+), 0 deletions(-)

 diff --git a/arch/powerpc/boot/dts/tqm8548.dts 
 b/arch/powerpc/boot/dts/tqm8548.dts
 index 81d3fbb..e5c3c67 100644
 --- a/arch/powerpc/boot/dts/tqm8548.dts
 +++ b/arch/powerpc/boot/dts/tqm8548.dts
 @@ -389,6 +389,11 @@
  reg = 3 0x0 0x800;
  fsl,upm-addr-offset = 0x10;
  fsl,upm-cmd-offset = 0x08;
 +wait-flags = 0x05;
 
 Should be at least fsl,upm-wait-flags. (And the flags should
 be documented in dts-bindings ;-).

OK.

 +/* Multi-chip device */
 +fsl,upm-mar-chip-offset = 0x200;
 +max-chips = 2;
 
 num-chips would be more appropriate, no?

Yep.

 
 +chip-offset = 0x200;
 
 I believe this is from some old code...

No, it's the address offset between the multiple chips. As Kumar already
pointed out, I also need to document the new properties.

Wolfgang.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


spidev.c driver on the ppc8247 (kernel 2.6.27.19)

2009-03-18 Thread Daniel Ng
Hi,

I'm trying to get the spidev.c driver working in Kernel 2.6.27.19 on a ppc8247.

Firstly, would I need to convert it to an 'of'-style driver?

Assuming this is the case, I've changed spidev_init() to use
of_register_platform_driver() with what I think is an appropriate
parameter:

static struct of_platform_driver spidev_spi = {
.name = spidev,
.match_table  = spidev_match,
.probe= spidev_probe,
.remove   = __devexit_p(spidev_remove),
};

spidev_probe() now looks like the below. I've had to change the
spidev_probe() function signature, which meant I needed to use
to_spi_device() in the function (there are no other changes).

static int __devinit spidev_probe(struct of_device *ofdev, const
struct of_device_id *match)
{
struct spidev_data  *spidev;
int status;
unsigned long   minor;
struct spi_device *spi;

spi = to_spi_device(ofdev-dev);

/* Allocate driver data */
spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
if (!spidev)
return -ENOMEM;

/* Initialize the driver data */
spidev-spi = spi;
spin_lock_init(spidev-spi_lock);
mutex_init(spidev-buf_lock);

INIT_LIST_HEAD(spidev-device_entry);

/* If we can allocate a minor number, hook up this device.
 * Reusing minors is fine so long as udev or mdev is working.
 */
mutex_lock(device_list_lock);
minor = find_first_zero_bit(minors, N_SPI_MINORS);
if (minor  N_SPI_MINORS) {
struct device *dev;

spidev-devt = MKDEV(SPIDEV_MAJOR, minor);

dev = device_create_drvdata(spidev_class, spi-dev,
spidev-devt, spidev,
spidev%d.%d,
spi-master-bus_num, spi-chip_select);
printk(spidev_probe(): CREATED spidev%d.%d\n,
spi-master-bus_num, spi-chip_select);
status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
.
.
/// (the rest of this function is unchanged)
.

}

It all executes ok until the above call to device_create_drvdata(),
where it crashes (see below). Can anyone explain why?

Can I still use the 'old-style' device_create_drvdata() function with
the 'of new-style' driver framework?

Am I going about this the right way?

Unable to handle kernel paging request for data at address 0x0120
Faulting instruction address: 0xc028e484
Oops: Kernel access of bad area, sig: 11 [#1]
PREEMPT XXX
NIP: c028e484 LR: c028e478 CTR: c01511c8
REGS: c1819d60 TRAP: 0300   Not tainted  (2.6.27.19-800-OS-03050107)
MSR: 9032 EE,ME,IR,DR  CR: 42044024  XER: 
DAR: 0120, DSISR: 2000
TASK = c1814400[1] 'swapper' THREAD: c1818000
GPR00: c028e478 c1819e10 c1814400 000b 150c 0e40 0008 c027
GPR08: f038  150c c1818000 f020 fffe 01ff8000 
GPR16: 01fed694 01ff56f0     c02d c184ec10
GPR24: c02d2610 c1963288 c02d260c c02aafa4  ffed c1963280 c184ec10
NIP [c028e484] spidev_probe+0xec/0x1c8
LR [c028e478] spidev_probe+0xe0/0x1c8
Call Trace:
[c1819e10] [c028e478] spidev_probe+0xe0/0x1c8 (unreliable)
[c1819e40] [c01814a4] of_platform_device_probe+0x5c/0x84
[c1819e60] [c01552c8] driver_probe_device+0xe8/0x240
[c1819e90] [c01554a4] __driver_attach+0x84/0x88
[c1819eb0] [c01548fc] bus_for_each_dev+0x5c/0x98
[c1819ee0] [c01550a0] driver_attach+0x24/0x34
[c1819ef0] [c0154eac] bus_add_driver+0x1b4/0x220
[c1819f10] [c01557b4] driver_register+0x5c/0x158
[c1819f30] [c018136c] of_register_driver+0x54/0x70
[c1819f40] [c0289a28] spidev_init+0x6c/0xf8
[c1819f60] [c00038e8] do_one_initcall+0x38/0x188
[c1819fd0] [c0278180] kernel_init+0x8c/0xf8
[c1819ff0] [c000f6fc] kernel_thread+0x44/0x60
Instruction dump:
4be90481 2b83001f 7c7c1b78 419d00d8 64600e40 901e 3c60c027 38638f04
4bd8ea31 813f0120 80be 3ce0c027 a9090120 38e78f10 893f0128 7fe4fb78
---[ end trace 8d59482f3bf88fe6 ]---

Cheers,
Daniel
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/4] NAND: FSL-UPM: add multi chip support

2009-03-18 Thread Wolfgang Grandegger
Anton Vorontsov wrote:
 On Tue, Mar 17, 2009 at 10:12:19AM +0100, Wolfgang Grandegegr wrote:
 From: Wolfgang Grandegger w...@grandegger.com

 This patch adds support for multi-chip NAND devices to the FSL-UPM
 driver. This requires support for multiple GPIOs for the RNB pins.

 Signed-off-by: Wolfgang Grandegger w...@grandegger.com
 ---
  drivers/mtd/nand/fsl_upm.c |   90 
 +--
  1 files changed, 69 insertions(+), 21 deletions(-)

 diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
 index 7815a40..ca7e85a 100644
 --- a/drivers/mtd/nand/fsl_upm.c
 +++ b/drivers/mtd/nand/fsl_upm.c
 @@ -23,6 +23,8 @@
  #include linux/io.h
  #include asm/fsl_lbc.h
  
 +#define FSL_UPM_NAND_MAX_CHIPS 4
 
 Is there any reason to hardcode max chips? Some obscure limit in the
 UPMs maybe?

Not really. It's limited by NAND_MAX_CHIP. See
http://lxr.linux.no/linux+v2.6.28.8/include/linux/mtd/nand.h#L40

 Otherwise we'd better allocate the rnb_gpios dynamically, depending
 on the num-chips property.

Could be done.

Wolfgang.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: IDE cable detection on Apple PowerBook

2009-03-18 Thread Benjamin Herrenschmidt
On Wed, 2009-03-18 at 14:06 +0900, TOMARI Hisanobu wrote:
 Hello,
 
 I'm using an OCZ PATA SSD on Apple PowerBook5,4 computer.
 The IDE drive fails to recognize 80-conductor cable that
 connects the drive to motherboard to fall back to UDMA33.
 
 This patch fixes this behavior by assuming that the cable is
 short-40pin when the model string matches PowerBook5 and 
 the motherboard detects 80c cable.
 
 This patch is against drivers/ide/pmac.c in linux 2.6.28.8.

The patch is too much of an ad-hoc hack... _maybe_ an option is to make
the core fallback to 40 short when 80 pin detection fails on
powerbooks instead ?

Ben.

 (before applying the patch) hdparm -i /dev/hda
 /dev/hda:
  Timing buffered disk reads:   90 MB in  3.03 seconds =  29.73 MB/sec
 (dmesg 2.6.26)
 ide0: Found Apple UniNorth ATA-6 controller, bus ID 3, irq 39
 Probing IDE interface ide0...
 hda: CORE_PATA, ATA DISK drive
 hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
 hda: drive side 80-wire cable detection failed, limiting max speed to UDMA33
 hda: UDMA/33 mode selected
 
 (after applying the patch) hdparm -i /dev/hda
 /dev/hda:
  Timing buffered disk reads:  240 MB in  3.02 seconds =  79.42 MB/sec
 (dmesg 2.6.28.8)
 ide-pmac: Found Apple UniNorth ATA-6 controller (PCI), bus ID 3, irq 39
 Probing IDE interface ide0...
 hda: CORE_PATA, ATA DISK drive
 hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
 hda: UDMA/100 mode selected
 ide0 at 0xf102a000-0xf102a070,0xf102a160 on irq 39
 
 
 ___
 Linuxppc-dev mailing list
 Linuxppc-dev@ozlabs.org
 https://ozlabs.org/mailman/listinfo/linuxppc-dev

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/3] powerpc: bare minimum checkpoint/restart implementation

2009-03-18 Thread Oren Laadan

An alternative: the task that created the container namely, is the parent
(outside the container) of the container init(1). In turn, init(1) creates
a special 'monitor' thread that monitors the restart, and the outside task
reaps the exit status of that thread (and only that thread).

[Hmmm... thinking about this - what happens if the container init(1) calls
clone() with CLONE_PARENT ??  does it not generate sort of a competing
container init(1) ??!!

Oren.


Cedric Le Goater wrote:
 Again, how would 'cr' obtain exit status for these tasks, and how would
 it distinguish failure from normal operation?
 
 Here's our solution to this issue.
 
 mcr maintains in its kernel container object an exitcode attribute for 
 the mcr-restart process. This process is detached from the fork tree of 
 the restarted application.  
 
 when the restart is finished, an mcr-wait command can be called to reap 
 this exitcode. This make it possible to distinguish an exit of the 
 application process from an exit of the mcr-restart process.
 
 This is a must-have for batch managers in an HPC environment. 
 
 Cheers,
 
 C.
 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


AW: spidev.c driver on the ppc8247 (kernel 2.6.27.19)

2009-03-18 Thread Stepanov, Sergej
Hi Daniel,

in the attachment i send a spi driver (little bit of) done by myself
1.
to init it you can use the following in your dts-file
s...@f000 {
...
c...@119c0 {
...
s...@11aa0 {
device_type = spi;
compatible = platform-mapped;
interrupts = 0x3F 8;
interrupt-parent = pic;
reg = 0x11AA0 0x60 0x89FC 2;
};
...
   }
2.
in driver/spi/Makefile
+obj-$(CONFIG_SPI_IDS8247)  += spi_ids8247.o
3.
In driver/spi/Kconfig
config SPI_IDS8247
tristate Freescale IDS8247 SPI controller
depends on PPC_82xx  EXPERIMENTAL
help
  This enables using the Freescale MPC8247
  controllers in master mode.

  Note, this driver uniquely supports the SPI controller on the MPC82xx
  family of PowerPC processors.
   This driver uses a simple set of shift registers for data
  (opposed to the CPM based descriptor model).
4.
This version is for 2.6.27 kernel on ppc8247.
May be it help you and would be a bit faster for you.

Best regards
Sergej.


Von: linuxppc-dev-bounces+sergej.stepanov=ids...@ozlabs.org 
[linuxppc-dev-bounces+sergej.stepanov=ids...@ozlabs.org] im Auftrag von Daniel 
Ng [daniel.ng1...@gmail.com]
Gesendet: Mittwoch, 18. März 2009 08:36
An: linuxppc-dev@ozlabs.org
Betreff: spidev.c driver on the ppc8247 (kernel 2.6.27.19)

Hi,

I'm trying to get the spidev.c driver working in Kernel 2.6.27.19 on a ppc8247.

Firstly, would I need to convert it to an 'of'-style driver?

Assuming this is the case, I've changed spidev_init() to use
of_register_platform_driver() with what I think is an appropriate
parameter:

static struct of_platform_driver spidev_spi = {
.name = spidev,
.match_table  = spidev_match,
.probe= spidev_probe,
.remove   = __devexit_p(spidev_remove),
};

spidev_probe() now looks like the below. I've had to change the
spidev_probe() function signature, which meant I needed to use
to_spi_device() in the function (there are no other changes).

static int __devinit spidev_probe(struct of_device *ofdev, const
struct of_device_id *match)
{
struct spidev_data  *spidev;
int status;
unsigned long   minor;
struct spi_device *spi;

spi = to_spi_device(ofdev-dev);

/* Allocate driver data */
spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
if (!spidev)
return -ENOMEM;

/* Initialize the driver data */
spidev-spi = spi;
spin_lock_init(spidev-spi_lock);
mutex_init(spidev-buf_lock);

INIT_LIST_HEAD(spidev-device_entry);

/* If we can allocate a minor number, hook up this device.
 * Reusing minors is fine so long as udev or mdev is working.
 */
mutex_lock(device_list_lock);
minor = find_first_zero_bit(minors, N_SPI_MINORS);
if (minor  N_SPI_MINORS) {
struct device *dev;

spidev-devt = MKDEV(SPIDEV_MAJOR, minor);

dev = device_create_drvdata(spidev_class, spi-dev,
spidev-devt, spidev,
spidev%d.%d,
spi-master-bus_num, spi-chip_select);
printk(spidev_probe(): CREATED spidev%d.%d\n,
spi-master-bus_num, spi-chip_select);
status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
.
.
/// (the rest of this function is unchanged)
.

}

It all executes ok until the above call to device_create_drvdata(),
where it crashes (see below). Can anyone explain why?

Can I still use the 'old-style' device_create_drvdata() function with
the 'of new-style' driver framework?

Am I going about this the right way?

Unable to handle kernel paging request for data at address 0x0120
Faulting instruction address: 0xc028e484
Oops: Kernel access of bad area, sig: 11 [#1]
PREEMPT XXX
NIP: c028e484 LR: c028e478 CTR: c01511c8
REGS: c1819d60 TRAP: 0300   Not tainted  (2.6.27.19-800-OS-03050107)
MSR: 9032 EE,ME,IR,DR  CR: 42044024  XER: 
DAR: 0120, DSISR: 2000
TASK = c1814400[1] 'swapper' THREAD: c1818000
GPR00: c028e478 c1819e10 c1814400 000b 150c 0e40 0008 c027
GPR08: f038  150c c1818000 f020 fffe 01ff8000 
GPR16: 01fed694 01ff56f0     c02d c184ec10
GPR24: c02d2610 c1963288 c02d260c c02aafa4  ffed c1963280 c184ec10
NIP [c028e484] spidev_probe+0xec/0x1c8
LR [c028e478] spidev_probe+0xe0/0x1c8
Call Trace:
[c1819e10] [c028e478] spidev_probe+0xe0/0x1c8 (unreliable)
[c1819e40] [c01814a4] of_platform_device_probe+0x5c/0x84
[c1819e60] [c01552c8] driver_probe_device+0xe8/0x240
[c1819e90] [c01554a4] 

PPC Linux and PCIe Hot-Plugging.

2009-03-18 Thread Mark Pearson

Hi,

I have a request from a client to support PCIe hot plugging on an PowerPC Linux 
platform.

I have had a general look into how Linux supports PCIe hot plugging, i.e. 
pciehp utilising ACPI firmware.

I'm not too familiar with the PowerPC platform and I'm not sure if ACPI is 
supported at all on the PowerPC platforms?

Does anyone know if PCIe hot plug support is available in PowerPC Linux?

Best regards, Mark.



  
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH v3 0/2] powerpc/86xx: Board support for GE Fanuc PPC9A

2009-03-18 Thread Martyn Welch
The following series implements basic support for the GE Fanuc PPC9A, a
6U single board computer, based on the Freescale MPC8641D.

This series provides:
 - The ability to boot the board with a serial console.
 - Ethernet support.
 - Sata and USB.
 - Support for one of the 2 available watchdog timers.
 - Support for the onboard temperature sensors
 - Support for the onboard RTC

v2: Corrections to DTS as suggested by David Gibson

v3: Further DTS corrections as suggested by David Gibson

Note: I have left the original wtd compatible tag in as well, so as to avoid 
having to make more changes to the wdt code for this patch (as this will require
the DTS files for the other boards to also be changed). I have changed the 
reference in the board file WRT the PIC, so the legacy value is not needed here.

Martyn

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH v3 1/2] powerpc/86xx: Board support for GE Fanuc's PPC9A

2009-03-18 Thread Martyn Welch
Support for the PPC9A VME Single Board Computer from GE Fanuc (PowerPC
MPC8641D).

This is the basic board support for GE Fanuc's PPC9A, a 6U single board
computer, based on Freescale's MPC8641D.

Signed-off-by: Martyn Welch martyn.we...@gefanuc.com
---

 arch/powerpc/boot/dts/gef_ppc9a.dts |  364 +++
 arch/powerpc/platforms/86xx/Kconfig |   10 +
 arch/powerpc/platforms/86xx/Makefile|1 
 arch/powerpc/platforms/86xx/gef_ppc9a.c |  223 +++
 drivers/watchdog/Kconfig|2 
 5 files changed, 598 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/dts/gef_ppc9a.dts 
b/arch/powerpc/boot/dts/gef_ppc9a.dts
new file mode 100644
index 000..dac7f8b
--- /dev/null
+++ b/arch/powerpc/boot/dts/gef_ppc9a.dts
@@ -0,0 +1,364 @@
+/*
+ * GE Fanuc PPC9A Device Tree Source
+ *
+ * Copyright 2008 GE Fanuc Intelligent Platforms Embedded Systems, Inc.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ * Based on: SBS CM6 Device Tree Source
+ * Copyright 2007 SBS Technologies GmbH  Co. KG
+ * And: mpc8641_hpcn.dts (MPC8641 HPCN Device Tree Source)
+ * Copyright 2006 Freescale Semiconductor Inc.
+ */
+
+/*
+ * Compiled with dtc -I dts -O dtb -o gef_ppc9a.dtb gef_ppc9a.dts
+ */
+
+/dts-v1/;
+
+/ {
+   model = GEF_PPC9A;
+   compatible = gef,ppc9a;
+   #address-cells = 1;
+   #size-cells = 1;
+
+   aliases {
+   ethernet0 = enet0;
+   ethernet1 = enet1;
+   serial0 = serial0;
+   serial1 = serial1;
+   pci0 = pci0;
+   };
+
+   cpus {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   PowerPC,8...@0 {
+   device_type = cpu;
+   reg = 0;
+   d-cache-line-size = 32;   // 32 bytes
+   i-cache-line-size = 32;   // 32 bytes
+   d-cache-size = 32768; // L1, 32K
+   i-cache-size = 32768; // L1, 32K
+   timebase-frequency = 0;   // From uboot
+   bus-frequency = 0;// From uboot
+   clock-frequency = 0;  // From uboot
+   };
+   PowerPC,8...@1 {
+   device_type = cpu;
+   reg = 1;
+   d-cache-line-size = 32;   // 32 bytes
+   i-cache-line-size = 32;   // 32 bytes
+   d-cache-size = 32768; // L1, 32K
+   i-cache-size = 32768; // L1, 32K
+   timebase-frequency = 0;   // From uboot
+   bus-frequency = 0;// From uboot
+   clock-frequency = 0;  // From uboot
+   };
+   };
+
+   memory {
+   device_type = memory;
+   reg = 0x0 0x4000; // set by uboot
+   };
+
+   local...@fef05000 {
+   #address-cells = 2;
+   #size-cells = 1;
+   compatible = fsl,mpc8641-localbus, simple-bus;
+   reg = 0xfef05000 0x1000;
+   interrupts = 19 2;
+   interrupt-parent = mpic;
+
+   ranges = 0 0 0xff00 0x0100 // 16MB Boot flash
+ 1 0 0xe800 0x0800 // Paged Flash 0
+ 2 0 0xe000 0x0800 // Paged Flash 1
+ 3 0 0xfc10 0x0002 // NVRAM
+ 4 0 0xfc00 0x8000 // FPGA
+ 5 0 0xfc008000 0x8000 // AFIX FPGA
+ 6 0 0xfd00 0x0080 // IO FPGA (8-bit)
+ 7 0 0xfd80 0x0080;   // IO FPGA (32-bit)
+
+   /* fl...@0,0 is a mirror of part of the memory in fl...@1,0
+   fl...@0,0 {
+   compatible = gef,ppc9a-firmware-mirror, cfi-flash;
+   reg = 0x0 0x0 0x100;
+   bank-width = 4;
+   device-width = 2;
+   #address-cells = 1;
+   #size-cells = 1;
+   partit...@0 {
+   label = firmware;
+   reg = 0x0 0x100;
+   read-only;
+   };
+   };
+   */
+
+   fl...@1,0 {
+   compatible = gef, ppc9a-paged-flash, cfi-flash;
+   reg = 0x1 0x0 0x800;
+   bank-width = 4;
+   device-width = 2;
+   #address-cells = 1;
+ 

[PATCH v3 2/2] powerpc/86xx: Default configuration for GE Fanuc's PPC9A

2009-03-18 Thread Martyn Welch
Support for the PPC9A VME Single Board Computer from GE Fanuc (PowerPC
MPC8641D).

This is the default config file for GE Fanuc's PPC9A, a 6U single board
computer, based on Freescale's MPC8641D.

Signed-off-by: Martyn Welch martyn.we...@gefanuc.com
---

 arch/powerpc/configs/86xx/gef_ppc9a_defconfig | 1889 +
 1 files changed, 1889 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/configs/86xx/gef_ppc9a_defconfig 
b/arch/powerpc/configs/86xx/gef_ppc9a_defconfig
new file mode 100644
index 000..df2c163
--- /dev/null
+++ b/arch/powerpc/configs/86xx/gef_ppc9a_defconfig
@@ -0,0 +1,1889 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.29-rc7
+# Fri Mar 13 15:36:11 2009
+#
+# CONFIG_PPC64 is not set
+
+#
+# Processor support
+#
+CONFIG_6xx=y
+# CONFIG_PPC_85xx is not set
+# CONFIG_PPC_8xx is not set
+# CONFIG_40x is not set
+# CONFIG_44x is not set
+# CONFIG_E200 is not set
+CONFIG_PPC_FPU=y
+# CONFIG_PHYS_64BIT is not set
+CONFIG_ALTIVEC=y
+CONFIG_PPC_STD_MMU=y
+CONFIG_PPC_STD_MMU_32=y
+# CONFIG_PPC_MM_SLICES is not set
+CONFIG_SMP=y
+CONFIG_NR_CPUS=2
+CONFIG_PPC32=y
+CONFIG_WORD_SIZE=32
+# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
+CONFIG_MMU=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_HARDIRQS=y
+# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
+CONFIG_IRQ_PER_CPU=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_LOCKBREAK=y
+CONFIG_ARCH_HAS_ILOG2_U32=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_GPIO=y
+# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
+CONFIG_PPC=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_OMIT_FRAME_POINTER=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_PPC_OF=y
+CONFIG_OF=y
+CONFIG_PPC_UDBG_16550=y
+CONFIG_GENERIC_TBSYNC=y
+CONFIG_AUDIT_ARCH=y
+CONFIG_GENERIC_BUG=y
+CONFIG_DEFAULT_UIMAGE=y
+# CONFIG_PPC_DCR_NATIVE is not set
+# CONFIG_PPC_DCR_MMIO is not set
+CONFIG_DEFCONFIG_LIST=/lib/modules/$UNAME_RELEASE/.config
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION=
+CONFIG_LOCALVERSION_AUTO=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+CONFIG_USER_SCHED=y
+# CONFIG_CGROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
+CONFIG_RELAY=y
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_COMPAT_BRK=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_PCI_QUIRKS=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_KPROBES is not set
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_HAVE_IOREMAP_PROT=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+CONFIG_USE_GENERIC_SMP_HELPERS=y
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_STOP_MACHINE=y
+CONFIG_BLOCK=y
+# CONFIG_LBD is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED=cfq
+# CONFIG_FREEZER is not set
+
+#
+# Platform support
+#
+CONFIG_PPC_MULTIPLATFORM=y
+CONFIG_CLASSIC32=y
+# CONFIG_PPC_CHRP is not set
+# CONFIG_MPC5121_ADS is not set
+# CONFIG_MPC5121_GENERIC is not set
+# CONFIG_PPC_MPC52xx is not set
+# CONFIG_PPC_PMAC is not set
+# CONFIG_PPC_CELL is not set
+# 

About [AMCC 460EX/canyonlands board] Synopsys DesignWare Cores (DWC) SATA host driver

2009-03-18 Thread Cheng Renquan
Mark,
  I found that the current sata_dwc can only work on
DENX-2.6.25-stable, and have problems in DENX-2.6.26, 27, 28,
29(master),
the boot errors is as the following, I hope you and AMCC staff submit
it into mainline soon, thanks.

there is also some other boot panic kmsg, I will reproduce it tomorrow.

http://git.denx.de/linux-2.6-denx.git/

Synopsys DesignWare Cores (DWC) SATA host driver

linuxppc-dev@ozlabs.org

About AMCC DesignWare Core SATA controller driver:

= boot
Using ip address 172.16.90.27
## Booting kernel from Legacy Image at ff60 ...
   Image Name:   Linux-2.6.27.19
   Created:  2009-03-13  10:18:17 UTC
   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
   Data Size:1574261 Bytes =  1.5 MB
   Load Address: 
   Entry Point:  
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
## Flattened Device Tree blob at fc1e
   Booting using the fdt blob at 0xfc1e
## Loading init Ramdisk from Legacy Image at fc20 ...
   Image Name:   canyonlands ramdisk rev. 001
   Created:  2008-05-13  11:18:24 UTC
   Image Type:   PowerPC Linux RAMDisk Image (gzip compressed)
   Data Size:18968362 Bytes = 18.1 MB
   Load Address: 
   Entry Point:  
   Verifying Checksum ... OK
   Loading Device Tree to 007fa000, end 007f ... OK
   Loading Ramdisk to 1ec3d000, end 1fe53f2a ... OK
Using Canyonlands machine description
Linux version 2.6.27.19 (fed...@ubox-h1) (gcc version 4.2.2) #1 Fri
Mar 13 18:18:05 HKT 2009
Found initrd at 0xdec3d000:0xdfe53f2a
Zone PFN ranges:
  DMA  0x - 0x0002
  Normal   0x0002 - 0x0002
  HighMem  0x0002 - 0x0002


scsi 0:0:0:0: Direct-Access ATA  WDC WD10EVVS-63E 01.0 PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] 1953525168 512-byte hardware sectors (1000205 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
support DPO or FUA
sd 0:0:0:0: [sda] 1953525168 512-byte hardware sectors (1000205 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
support DPO or FUA
 sda:3ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
 res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
ata1.00: status: { DRDY }
ata1: link is slow to respond, please be patient (ready=0)
ata1: prereset failed (errno=-16)
ata1: reset failed, giving up
ata1.00: disabled
ata1: EH complete
sd 0:0:0:0: [sda] Result: hostbyte=0x04 driverbyte=0x00
end_request: I/O error, dev sda, sector 0
Buffer I/O error on device sda, logical block 0
sd 0:0:0:0: [sda] Result: hostbyte=0x04 driverbyte=0x00
end_request: I/O error, dev sda, sector 0
Buffer I/O error on device sda, logical block 0
 unable to read partition table
sd 0:0:0:0: [sda] Attached SCSI disk
4cc00.nor_flash: Found 1 x16 devices at 0x0 in 16-bit bank
 Amd/Fujitsu Extended Query Table at 0x0040
4cc00.nor_flash: CFI does not contain boot bank location. Assuming top.
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
RedBoot partition parsing not available
Creating 7 MTD partitions on 4cc00.nor_flash:
0x-0x001e : kernel
0x001e-0x0020 : dtb
0x0020-0x0160 : ramdisk
0x0160-0x01a0 : jffs2
0x01a0-0x03f6 : user
0x03f6-0x03fa : env
0x03fa-0x0400 : u-boot
NDFC NAND Driver initialized. Chip-Rev: 0x0111
NAND device: Manufacturer ID: 0x20, Chip ID: 0xf1 (ST Micro NAND
128MiB 3,3V 8-bit)
Scanning device for bad blocks
Number of partitions 3
Creating 3 MTD partitions on NAND 128MiB 3,3V 8-bit:
0x-0x0010 : u-boot
0x0010-0x0014 : env
0x0014-0x0800 : content
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
dwc_otg: version 2.60a 22-NOV-2006
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
eth0: link is up, 1000 FDX, pause enabled
IP-Config: Complete:
 device=eth0, addr=172.16.90.27, mask=255.255.255.0, gw=255.255.255.255,
 host=canyonlands, domain=, nis-domain=(none),
 bootserver=172.16.90.26, rootserver=172.16.90.26, rootpath=
RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem).
Freeing unused kernel memory: 156k init
Startup utility found. Executing...
AMCC Startup utility launched.


BusyBox v1.2.1 (2008.05.13-11:11+) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ # fdisk -l
sd 0:0:0:0: [sda] Result: hostbyte=0x04 driverbyte=0x00
end_request: I/O error, dev sda, sector 8
Buffer I/O error on device sda, logical block 1
sd 0:0:0:0: [sda] Result: hostbyte=0x04 driverbyte=0x00
end_request: I/O error, dev sda, sector 16
Buffer I/O error on device sda, logical block 2
sd 0:0:0:0: [sda] Result: 

Re: [PATCH 1/4] NAND: FSL-UPM: add multi chip support

2009-03-18 Thread Anton Vorontsov
On Wed, Mar 18, 2009 at 08:41:17AM +0100, Wolfgang Grandegger wrote:
 Anton Vorontsov wrote:
  On Tue, Mar 17, 2009 at 10:12:19AM +0100, Wolfgang Grandegegr wrote:
  From: Wolfgang Grandegger w...@grandegger.com
 
  This patch adds support for multi-chip NAND devices to the FSL-UPM
  driver. This requires support for multiple GPIOs for the RNB pins.
 
  Signed-off-by: Wolfgang Grandegger w...@grandegger.com
  ---
   drivers/mtd/nand/fsl_upm.c |   90 
  +--
   1 files changed, 69 insertions(+), 21 deletions(-)
 
  diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
  index 7815a40..ca7e85a 100644
  --- a/drivers/mtd/nand/fsl_upm.c
  +++ b/drivers/mtd/nand/fsl_upm.c
  @@ -23,6 +23,8 @@
   #include linux/io.h
   #include asm/fsl_lbc.h
   
  +#define FSL_UPM_NAND_MAX_CHIPS 4
  
  Is there any reason to hardcode max chips? Some obscure limit in the
  UPMs maybe?
 
 Not really. It's limited by NAND_MAX_CHIP. See
 http://lxr.linux.no/linux+v2.6.28.8/include/linux/mtd/nand.h#L40

OK, then you could just use that constant, since we'll only allocate
the 8 ints.

Thanks,

-- 
Anton Vorontsov
email: cbouatmai...@gmail.com
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v2 2/2] powerpc/83xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Kumar Gala


On Mar 17, 2009, at 1:59 PM, Anton Vorontsov wrote:


Currently it doesn't matter where the mdio nodes are placed, but with
power management support (i.e. when sleep =  properties will take
effect), mdio nodes placement will become important: mdio controller
is a part of the ethernet block, so the mdio nodes should be placed
correctly. Otherwise we may wrongly assume that MDIO controllers are
available during sleep.

Suggested-by: Scott Wood scottw...@freescale.com
Signed-off-by: Anton Vorontsov avoront...@ru.mvista.com
---

Changes since RFC:
- Don't use compatible = simple-bus for gianfar nodes.

arch/powerpc/boot/dts/mpc8315erdb.dts |   80 +++ 
+-
arch/powerpc/boot/dts/mpc8349emitx.dts|   69  
+---

arch/powerpc/boot/dts/mpc8349emitxgp.dts  |   42 ---
arch/powerpc/boot/dts/mpc834x_mds.dts |   81 +++ 
+-
arch/powerpc/boot/dts/mpc8377_mds.dts |   80 +++ 
+-
arch/powerpc/boot/dts/mpc8377_rdb.dts |   67  
+---
arch/powerpc/boot/dts/mpc8378_mds.dts |   80 +++ 
+-
arch/powerpc/boot/dts/mpc8378_rdb.dts |   69 + 
+---
arch/powerpc/boot/dts/mpc8379_mds.dts |   79 +++ 
+
arch/powerpc/boot/dts/mpc8379_rdb.dts |   66  
+--

arch/powerpc/platforms/83xx/mpc834x_itx.c |1 +
arch/powerpc/platforms/83xx/mpc834x_mds.c |1 +
arch/powerpc/platforms/83xx/mpc837x_mds.c |1 +
arch/powerpc/platforms/83xx/mpc837x_rdb.c |1 +
14 files changed, 398 insertions(+), 319 deletions(-)


If we do this we should also fixup all the 85xx  86xx .dts

diff --git a/arch/powerpc/boot/dts/mpc8315erdb.dts b/arch/powerpc/ 
boot/dts/mpc8315erdb.dts

index 88d691c..c0d5b34 100644
--- a/arch/powerpc/boot/dts/mpc8315erdb.dts
+++ b/arch/powerpc/boot/dts/mpc8315erdb.dts
@@ -190,66 +190,74 @@
phy_type = utmi;
};


[snip]



enet0: ether...@24000 {
+   #address-cells = 1;
+   #size-cells = 1;
cell-index = 0;
device_type = network;
model = eTSEC;
compatible = gianfar;
reg = 0x24000 0x1000;
+   ranges;


Can this be proper?
ranges = 0x0 0x24520 0x20;


local-mac-address = [ 00 00 00 00 00 00 ];
interrupts = 32 0x8 33 0x8 34 0x8;
interrupt-parent = ipic;
tbi-handle = tbi0;
phy-handle =  phy0 ;
+
+   m...@24520 {
+   #address-cells = 1;
+   #size-cells = 0;
+   compatible = fsl,gianfar-mdio;
+   reg = 0x24520 0x20;


update here for ranges change.



+
+   phy0: ethernet-...@0 {
+   interrupt-parent = ipic;
+   interrupts = 20 0x8;
+   reg = 0x0;
+   device_type = ethernet-phy;
+   };
+
+   phy1: ethernet-...@1 {
+   interrupt-parent = ipic;
+   interrupts = 19 0x8;
+   reg = 0x1;
+   device_type = ethernet-phy;
+   };
+
+   tbi0: tbi-...@11 {
+   reg = 0x11;
+   device_type = tbi-phy;
+   };
+   };
};


- k
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: IDE cable detection on Apple PowerBook

2009-03-18 Thread TOMARI Hisanobu
I thought the short-40pin assumption would cause no problem
considering all models beginning with PowerBook5 are laptops.
Do you mean an option to toggle this hack on/off should be present 
in Kconfig?

Thanks,
TOMARI Hisanobu

On Wed, 18 Mar 2009 18:58:17 +1100
Benjamin Herrenschmidt b...@kernel.crashing.org wrote:

 On Wed, 2009-03-18 at 14:06 +0900, TOMARI Hisanobu wrote:
  Hello,
  
  I'm using an OCZ PATA SSD on Apple PowerBook5,4 computer.
  The IDE drive fails to recognize 80-conductor cable that
  connects the drive to motherboard to fall back to UDMA33.
  
  This patch fixes this behavior by assuming that the cable is
  short-40pin when the model string matches PowerBook5 and 
  the motherboard detects 80c cable.
  
  This patch is against drivers/ide/pmac.c in linux 2.6.28.8.
 
 The patch is too much of an ad-hoc hack... _maybe_ an option is to make
 the core fallback to 40 short when 80 pin detection fails on
 powerbooks instead ?
 
 Ben.
 
  (before applying the patch) hdparm -i /dev/hda
  /dev/hda:
   Timing buffered disk reads:   90 MB in  3.03 seconds =  29.73 MB/sec
  (dmesg 2.6.26)
  ide0: Found Apple UniNorth ATA-6 controller, bus ID 3, irq 39
  Probing IDE interface ide0...
  hda: CORE_PATA, ATA DISK drive
  hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
  hda: drive side 80-wire cable detection failed, limiting max speed to UDMA33
  hda: UDMA/33 mode selected
  
  (after applying the patch) hdparm -i /dev/hda
  /dev/hda:
   Timing buffered disk reads:  240 MB in  3.02 seconds =  79.42 MB/sec
  (dmesg 2.6.28.8)
  ide-pmac: Found Apple UniNorth ATA-6 controller (PCI), bus ID 3, irq 39
  Probing IDE interface ide0...
  hda: CORE_PATA, ATA DISK drive
  hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
  hda: UDMA/100 mode selected
  ide0 at 0xf102a000-0xf102a070,0xf102a160 on irq 39
  
  
  ___
  Linuxppc-dev mailing list
  Linuxppc-dev@ozlabs.org
  https://ozlabs.org/mailman/listinfo/linuxppc-dev
 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v2 2/2] powerpc/83xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Anton Vorontsov
On Wed, Mar 18, 2009 at 08:21:18AM -0500, Kumar Gala wrote:
[...]
 arch/powerpc/platforms/83xx/mpc834x_mds.c |1 +
 arch/powerpc/platforms/83xx/mpc837x_mds.c |1 +
 arch/powerpc/platforms/83xx/mpc837x_rdb.c |1 +
 14 files changed, 398 insertions(+), 319 deletions(-)

 If we do this we should also fixup all the 85xx  86xx .dts

OK.

It would be great to have #include gianfar_enet.dts facility in .dts
files. ;-) I heard some rumors about this, what was the consequence?..

[...]
 +ranges;

 Can this be proper?
   ranges = 0x0 0x24520 0x20;

Yes, will change.

I was actually asking that q in RFC, i.e. whether we want
proper ranges or these stubs (I took stubs approach since
it's already in mpc8313_rdb device tree).

Thanks,

-- 
Anton Vorontsov
email: cbouatmai...@gmail.com
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Fix for __div64_32 locks when using some 64 bit numbers

2009-03-18 Thread davidastro


Benjamin Herrenschmidt wrote:
 
 On Tue, 2009-03-17 at 14:15 -0700, davidastro wrote:
 I found a bug when using the function __div64_32 in assembly in a 32 bit
 ppc
 architecture unit.
 
 I tried the numbers 5583456504800 for the dividend and 4294967079 for
 the divisor. When passing these two numbers to the function  __div64_32,
 I
 had a software lock. I searched for possible patches online and in
 different
 forums but I could not find anything related to the assembly
 implementation
 to this function (I would have to apologize if somebody already found a
 fix
 :-) ).
 
 Anyway, when analyzing the assembly code, I found out with gdb the
 problem.
 I am not an expert in ppc architecture but I read the documentation and I
 am
 pretty sure I solved the issue (I have been testing for couple of days
 using
 random 64 to 32 number combinations with good results).
 
 Who or Where should I post the fix to be reviewed.
 
 Here is fine :-)
 
 Ben.
 
 
 ___
 Linuxppc-dev mailing list
 Linuxppc-dev@ozlabs.org
 https://ozlabs.org/mailman/listinfo/linuxppc-dev
 
 


Basically, the numbers shown above was causing the 64 by 32 bit algorithm to
divide by zero making the unit spin and also giving incorrect results.
Here is the code as it was before.


#include asm/ppc_asm.h
#include asm/processor.h

_GLOBAL(__div64_32)
lwz r5,0(r3)# get the dividend into r5/r6
lwz r6,4(r3)
cmplw   r5,r4
li  r7,0
li  r8,0
blt 1f
divwu   r7,r5,r4# if dividend.hi = divisor,
mullw   r0,r7,r4# quotient.hi = dividend.hi / divisor
subf.   r5,r0,r5# dividend.hi %= divisor
beq 3f
1:  mr  r11,r5  # here dividend.hi != 0
andis.  r0,r5,0xc000
bne 2f
cntlzw  r0,r5   # we are shifting the dividend right
li  r10,-1  # to make it  2^32, and shifting
srw r10,r10,r0  # the divisor right the same amount,
add r9,r4,r10   # rounding up (so the estimate cannot
andcr11,r6,r10  # ever be too large, only too small)
andcr9,r9,r10  #THIS CODE COULD STORE A ZERO IN r9
or  r11,r5,r11
rotlw   r9,r9,r0
rotlw   r11,r11,r0
divwu   r11,r11,r9  # WARNING r9 COULD BE ZERO
2:  mullw   r10,r11,r4  # to get an estimate of the quotient,
mulhwu  r9,r11,r4   # multiply the estimate by the divisor,
subfc   r6,r10,r6   # take the product from the divisor,
add r8,r8,r11   # and add the estimate to the accumulated
subfe.  r5,r9,r5# quotient
bne 1b
3:  cmplw   r6,r4
blt 4f
divwu   r0,r6,r4# perform the remaining 32-bit division
mullw   r10,r0,r4   # and get the remainder
add r8,r8,r0
subfr6,r10,r6
4:  stw r7,0(r3)# return the quotient in *r3
stw r8,4(r3)
mr  r3,r6   # return the remainder in r3
blr
 

In the line in bold with the warning:
divwu   r11,r11,r9  # WARNING r9 COULD BE ZERO

r9 could be zero if giving the right number by the previous operation:
andcr9,r9,r10  #THIS CODE COULD STORE A ZERO IN r9

My propose solution is the following:

#include asm/ppc_asm.h
#include asm/processor.h

_GLOBAL(__div64_32)
lwz r5,0(r3)# get the dividend into r5/r6
lwz r6,4(r3)
cmplw   r5,r4
li  r7,0
li  r8,0
blt 1f
divwu   r7,r5,r4# if dividend.hi = divisor,
mullw   r0,r7,r4# quotient.hi = dividend.hi / divisor
subf.   r5,r0,r5# dividend.hi %= divisor
beq 3f
1:  mr  r11,r5  # here dividend.hi != 0
andis.  r0,r5,0xc000
bne 2f
cntlzw  r0,r5   # we are shifting the dividend right
li  r10,-1  # to make it  2^32, and shifting
srw r10,r10,r0  # the divisor right the same amount,
add r9,r4,r10   # rounding up (so the estimate cannot
andcr11,r6,r10  # ever be too large, only too small)
andc.   r9,r9,r10   # Check result is not equal to zero (r9 
is
dividing later on)
bne 5f
li  r9,1# Magic number to avoid r9 = 0 
if ever happens
5: or   r11,r5,r11
rotlw   r9,r9,r0
rotlw   r11,r11,r0
divwu   r11,r11,r9  # then we divide the shifted quantities
2:  mullw   r10,r11,r4  # to get an estimate of the quotient,
mulhwu  r9,r11,r4   # multiply the estimate by the divisor,
subfc   r6,r10,r6   # take the product from the divisor,
add r8,r8,r11   # and add the estimate to the accumulated
subfe.  r5,r9,r5# 

Re: [PATCH v2 2/2] powerpc/83xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Scott Wood
On Wed, Mar 18, 2009 at 06:28:00PM +0300, Anton Vorontsov wrote:
 It would be great to have #include gianfar_enet.dts facility in .dts
 files. ;-) I heard some rumors about this, what was the consequence?..

You can already do a raw include, but in most cases it needs parameterized
templates/macros to make it useful.  There were some patches floating around
for that, but there was some disagreement about syntax and the discussion
seems to have died out.

 [...]
  +  ranges;
 
  Can this be proper?

It's proper, but a bit lazy. :-)

  ranges = 0x0 0x24520 0x20;
 
 Yes, will change.

I'd prefer ranges = 0 0x24000 0x1000, in case any other sub-blocks come
along in the future.

-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v2 2/2] powerpc/83xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Grant Likely
On Wed, Mar 18, 2009 at 9:43 AM, Scott Wood scottw...@freescale.com wrote:
 On Wed, Mar 18, 2009 at 06:28:00PM +0300, Anton Vorontsov wrote:
                      ranges = 0x0 0x24520 0x20;

 Yes, will change.

 I'd prefer ranges = 0 0x24000 0x1000, in case any other sub-blocks come
 along in the future.

FWIW, ditto.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC]PPC driver lock for DMA registers

2009-03-18 Thread Eddie Dawydiuk

Hello,

I'm working on SD card and Nand drivers that I would like to eventually submit 
for inclusion in the mainline kernel. This being my first kernel port being 
submitted upstream I was hoping for comments on my proposed design to ensure it 
would be excepted in the mainline kernel(from a design standpoint). We have an 
FPGA on our product that has an interface for transferring data via DMA. The SD 
card driver and Nand flash driver will both be accessing these registers. As a 
result I was planning on writing a dma driver(drivers/dma/ts81xx.c) that 
implements a function dma_op() that gets passed a physical address, virtual 
address, length, and read/write op and returns an int. I'd use a semaphore to 
protect the registers. I'd also implement a function dma_bus_init() for 
allocating a cache coherent buffer, initializing the semaphore, and ioremapping 
the FPGA regs.


I'd really appreciate any feedback or suggestions.

--
Best Regards,

 Eddie Dawydiuk, Technologic Systems | voice:  (480) 837-5200
 16525 East Laser Drive  | fax:(480) 837-5300
 Fountain Hills, AZ 85268| web: www.embeddedARM.com
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC]PPC driver lock for DMA registers

2009-03-18 Thread Grant Likely
On Wed, Mar 18, 2009 at 10:29 AM, Eddie Dawydiuk ed...@embeddedarm.com wrote:
 Hello,

 I'm working on SD card and Nand drivers that I would like to eventually
 submit for inclusion in the mainline kernel. This being my first kernel port
 being submitted upstream I was hoping for comments on my proposed design to
 ensure it would be excepted in the mainline kernel(from a design
 standpoint). We have an FPGA on our product that has an interface for
 transferring data via DMA. The SD card driver and Nand flash driver will
 both be accessing these registers. As a result I was planning on writing a
 dma driver(drivers/dma/ts81xx.c) that implements a function dma_op() that
 gets passed a physical address, virtual address, length, and read/write op
 and returns an int. I'd use a semaphore to protect the registers. I'd also
 implement a function dma_bus_init() for allocating a cache coherent buffer,
 initializing the semaphore, and ioremapping the FPGA regs.

Nothing that you describe here sounds off base, but the proof is in
the pudding so they say.  Best advice I can offer is to follow the
example of existing powerpc device drivers.  You'll need to describe
your FPGA interface in the .dts file and write an of_platform driver
that binds against it.  Make sure you post your proposed dts
description of the FPGA to the devicetree-disc...@ozlabs.org mailing
list before committing to it.  In you're device drivers .probe() hook
you would create and register the NAND and SD devices with the kernel
with the needed hooks to access the FPGA.

Here are some good examples of of_platform drivers to look at:

drivers/block/xsysace.c
drivers/spi/xilinx_spi.c
drivers/i2c/busses/i2c-ibm_iic.c

Cheers,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [RFC]PPC driver lock for DMA registers

2009-03-18 Thread Eddie Dawydiuk

Hello,


I'm working on SD card and Nand drivers that I would like to eventually
submit for inclusion in the mainline kernel. This being my first kernel port
being submitted upstream I was hoping for comments on my proposed design to
ensure it would be excepted in the mainline kernel(from a design
standpoint). We have an FPGA on our product that has an interface for
transferring data via DMA. The SD card driver and Nand flash driver will
both be accessing these registers. As a result I was planning on writing a
dma driver(drivers/dma/ts81xx.c) that implements a function dma_op() that
gets passed a physical address, virtual address, length, and read/write op
and returns an int. I'd use a semaphore to protect the registers. I'd also
implement a function dma_bus_init() for allocating a cache coherent buffer,
initializing the semaphore, and ioremapping the FPGA regs.


Nothing that you describe here sounds off base, but the proof is in
the pudding so they say.  Best advice I can offer is to follow the
example of existing powerpc device drivers.  You'll need to describe
your FPGA interface in the .dts file and write an of_platform driver
that binds against it.  Make sure you post your proposed dts
description of the FPGA to the devicetree-disc...@ozlabs.org mailing
list before committing to it.  In you're device drivers .probe() hook
you would create and register the NAND and SD devices with the kernel
with the needed hooks to access the FPGA.

Here are some good examples of of_platform drivers to look at:

drivers/block/xsysace.c
drivers/spi/xilinx_spi.c
drivers/i2c/busses/i2c-ibm_iic.c


Thanks for the suggestions, and the pointer to some reference drivers ;)


--
Best Regards,

 Eddie Dawydiuk, Technologic Systems | voice:  (480) 837-5200
 16525 East Laser Drive  | fax:(480) 837-5300
 Fountain Hills, AZ 85268| web: www.embeddedARM.com
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 1/2] powerpc/86xx: Board support for GE Fanuc's PPC9A

2009-03-18 Thread Wim Van Sebroeck
Hi Martyn,

 diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
 index c7352f7..ecf52e4 100644
 --- a/drivers/watchdog/Kconfig
 +++ b/drivers/watchdog/Kconfig
 @@ -772,7 +772,7 @@ config TXX9_WDT
  
  config GEF_WDT
   tristate GE Fanuc Watchdog Timer
 - depends on GEF_SBC610 || GEF_SBC310
 + depends on GEF_SBC610 || GEF_SBC310 || GEF_PPC9A
   ---help---
 Watchdog timer found in a number of GE Fanuc single board computers.

This part is Signed-off-by me. The rest I leave up to the powerpc maintainers.

Kind regards,
Wim.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Freescale MPC8313ERDB-RevA and newer BSP/kernel

2009-03-18 Thread Scott Wood
On Tue, Mar 17, 2009 at 12:52:52PM -0400, Mark Bishop wrote:
 Quoting Vijay Nikam vijay.t.ni...@gmail.com:

 Hi Mark,

 Could you please let me know how you booted the latest Linux kernel on
 MPC8313ERDB board ? ? ? As I tried but was not successful. It hangs or
 does nothing and waits at network configuration, mean to determine IP
 address (as I have used dhcp).

 Kindly please acknowledge ... thank you ...

 Kind Regards,
 Vijay Nikam



 I modified the .dts file (mpc8313erdb.dts)

 WAS interrupts = 37 0x8 36 0x8 35 0x8;
 IS  interrupts = 34 0x8 33 0x8 32 0x8;

Should actually be 32 8 33 8 34 8 for newer revs.

 WAS interrupts = 34 0x8 33 0x8 32 0x8;
 IS  interrupts = 37 0x8 36 0x8 35 0x8;

Likewise, 35 8 36 8 37 8.

-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 1/2] powerpc/86xx: Board support for GE Fanuc's PPC9A

2009-03-18 Thread Kumar Gala


On Mar 18, 2009, at 12:35 PM, Wim Van Sebroeck wrote:


Hi Martyn,


diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index c7352f7..ecf52e4 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -772,7 +772,7 @@ config TXX9_WDT

config GEF_WDT
tristate GE Fanuc Watchdog Timer
-   depends on GEF_SBC610 || GEF_SBC310
+   depends on GEF_SBC610 || GEF_SBC310 || GEF_PPC9A
---help---
	  Watchdog timer found in a number of GE Fanuc single board  
computers.


This part is Signed-off-by me. The rest I leave up to the powerpc  
maintainers.


Kind regards,
Wim.


Ok w/me adding an actually signed-of-by for you when I apply this?

- k

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 1/2] powerpc/86xx: Board support for GE Fanuc's PPC9A

2009-03-18 Thread Wim Van Sebroeck
Hi Kumar,

 diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
 index c7352f7..ecf52e4 100644
 --- a/drivers/watchdog/Kconfig
 +++ b/drivers/watchdog/Kconfig
 @@ -772,7 +772,7 @@ config TXX9_WDT

 config GEF_WDT
 tristate GE Fanuc Watchdog Timer
 -   depends on GEF_SBC610 || GEF_SBC310
 +   depends on GEF_SBC610 || GEF_SBC310 || GEF_PPC9A
 ---help---
   Watchdog timer found in a number of GE Fanuc single board  
 computers.

 This part is Signed-off-by me. The rest I leave up to the powerpc  
 maintainers.

 Kind regards,
 Wim.

 Ok w/me adding an actually signed-of-by for you when I apply this?

Yes, please add a signed-off-by for me when you apply this patch.

Kind regards,
Wim.

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: Confused about CLOCK_TICK_RATE

2009-03-18 Thread Scott Wood
On Thu, Mar 12, 2009 at 02:01:00PM -0500, Timur Tabi wrote:
 Can someone explain CLOCK_TICK_RATE to me?  It's defined in
 arch/powerpc/include/asm/timex.h as such:
 
 #define CLOCK_TICK_RATE   1024000 /* Underlying HZ */
 
 Every architecture defines this, but some use the better comment
 Underlying frequency of the HZ timer.
 
 My question is: why is this a constant? Shouldn't it be a variable,
 perhaps something that is based on tb_ticks_per_usec?

Looks like legacy crud, originally meant to be the PIT input frequency, that
isn't used for much on powerpc.  It was probably chosen so as to make HZ ==
ACTHZ for the supported values of HZ.

-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: node /dev/ttyCPM2 not created

2009-03-18 Thread Scott Wood
On Mon, Mar 16, 2009 at 05:39:08AM -0800, liran raz wrote:
 Thanks, I don't see any mdev process running.

Does it run during the boot scripts?  Or do you have udev?

 Just wonder who is creating /dev/ttyCPM1 since in the device table file
 (device_table.txt)
 I have only node: 204 (major) 46 (minor) defined.
 But I can see /dev/ttyCPM1 (204 47)

Ideally, it would be a program such as udev or mdev.  If you're using a
static /dev with no utility to automatically create nodes, then it's *you*
that creates it, with mknod. :-)

-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 4/4] powerpc/85xx: TQM8548: Update DTS file for multi-chip support

2009-03-18 Thread Scott Wood
On Tue, Mar 17, 2009 at 10:12:22AM +0100, Wolfgang Grandegegr wrote:
 --- a/arch/powerpc/boot/dts/tqm8548.dts
 +++ b/arch/powerpc/boot/dts/tqm8548.dts
 @@ -389,6 +389,11 @@
   reg = 3 0x0 0x800;
   fsl,upm-addr-offset = 0x10;
   fsl,upm-cmd-offset = 0x08;
 + wait-flags = 0x05;
 + /* Multi-chip device */
 + fsl,upm-mar-chip-offset = 0x200;
 + max-chips = 2;
 + chip-offset = 0x200;

Device-specific properties (especially vaguely-named ones like wait-flags)
should have at least an fsl, prefix (or better, an fsl,upm- or
fsl,upm-nand- prefix).

Please update Documentation/powerpc/dts-bindings/fsl/upm-nand.txt with the
definitions of these new properties.

-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH -next] gianfar, ucc_geth: Use proper address translation for MDIO buses

2009-03-18 Thread Anton Vorontsov
Currently the drivers just read reg property for constructing MDIO
bus IDs, but this won't work when we'll start using ranges =  in
the device tree, so this will pop up:

Gianfar MII Bus: probed
sysfs: duplicate filename 'm...@520' can not be created
[ cut here ]
Badness at c00c70c8 [verbose debug info unavailable]
NIP: c00c70c8 LR: c00c70c8 CTR: c018220c
REGS: cf82fc80 TRAP: 0700   Not tainted  (2.6.29-rc7-00607-g8deffe6)
MSR: 00029032 EE,ME,CE,IR,DR  CR: 22044022  XER: 2000
TASK = cf821bd0[1] 'swapper' THREAD: cf82e000
GPR00: c00c70c8 cf82fd30 cf821bd0 003b 13a4  c017f4f0 13a4
GPR08: c03becbc c03b1f5c 13a4 c03be810 22044022  0ffcd000 
GPR16: 0ffc2420 0ffc6eb8      
GPR24:   cf9d8c40 cf82fd78 cf86ec14 cf82fd48 cf9d78a4 ffef
NIP [c00c70c8] sysfs_add_one+0x4c/0x54
LR [c00c70c8] sysfs_add_one+0x4c/0x54
Call Trace:
[cf82fd30] [c00c70c8] sysfs_add_one+0x4c/0x54 (unreliable)
[cf82fd40] [c00c7628] create_dir+0x58/0xc0
[cf82fd70] [c00c76d0] sysfs_create_dir+0x40/0x70
[cf82fd90] [c0154d58] create_dir+0x28/0x78
[cf82fda0] [c01551f4] kobject_add_internal+0x98/0x13c
[cf82fdc0] [c0155868] kobject_add+0x60/0x98
[cf82fdf0] [c01854f4] device_add+0x98/0x2ac
[cf82fe10] [c01985d8] mdiobus_register+0xb4/0x1b8
[cf82fe30] [c0194f1c] gfar_mdio_probe+0x188/0x204
...

This patch fixes the issue by translating the reg property to a full
address, and thus avoids the duplicate names.

Signed-off-by: Anton Vorontsov avoront...@ru.mvista.com
---

This is for 2.6.30 since we don't use ranges =  yet.

David, I believe Kumar would like to pick this patch into his tree
along with a patch set that adds ranges =  properties to the
device tree... So would you mind if we take it via powerpc.git?

Thanks,

 drivers/net/gianfar_mii.c  |   10 +++---
 drivers/net/ucc_geth_mii.c |   10 +++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c
index f49a426..92bc1a7 100644
--- a/drivers/net/gianfar_mii.c
+++ b/drivers/net/gianfar_mii.c
@@ -193,11 +193,15 @@ static int *create_irq_map(struct device_node *np)
 
 void gfar_mdio_bus_name(char *name, struct device_node *np)
 {
-   const u32 *reg;
+   const u32 *addr;
+   u64 taddr = OF_BAD_ADDR;
 
-   reg = of_get_property(np, reg, NULL);
+   addr = of_get_address(np, 0, NULL, NULL);
+   if (addr)
+   taddr = of_translate_address(np, addr);
 
-   snprintf(name, MII_BUS_ID_SIZE, %...@%x, np-name, reg ? *reg : 0);
+   snprintf(name, MII_BUS_ID_SIZE, %...@%llx, np-name,
+   (unsigned long long)taddr);
 }
 
 /* Scan the bus in reverse, looking for an empty spot */
diff --git a/drivers/net/ucc_geth_mii.c b/drivers/net/ucc_geth_mii.c
index 0ada4ed..99cbd14 100644
--- a/drivers/net/ucc_geth_mii.c
+++ b/drivers/net/ucc_geth_mii.c
@@ -286,10 +286,14 @@ void uec_mdio_exit(void)
 
 void uec_mdio_bus_name(char *name, struct device_node *np)
 {
-const u32 *reg;
+   const u32 *addr;
+   u64 taddr = OF_BAD_ADDR;
 
-reg = of_get_property(np, reg, NULL);
+   addr = of_get_address(np, 0, NULL, NULL);
+   if (addr)
+   taddr = of_translate_address(np, addr);
 
-snprintf(name, MII_BUS_ID_SIZE, %...@%x, np-name, reg ? *reg : 0);
+   snprintf(name, MII_BUS_ID_SIZE, %...@%llx, np-name,
+   (unsigned long long)taddr);
 }
 
-- 
1.5.6.5
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[RFC] powerpc: i2c-mpc: make I2C bus speed configurable

2009-03-18 Thread Wolfgang Grandegger
The I2C driver for the MPC still uses a fixed clock divider hard-coded
into the driver. This issue has already been discussed twice:

 http://www.mail-archive.com/linuxppc-dev@ozlabs.org/msg21933.html
 http://www.mail-archive.com/linuxppc-dev@ozlabs.org/msg26923.html

Let's code speak ;-). The attached RFC patch used the following approach:

- the SOC property i2c-clock-frequency defines the frequency of the
  I2C source clock, which could be filled in by U-Boot. This avoids all
  the fiddling with getting the proper source clock frequency for the
  processor or board. I will provide a patch for U-Boot if this proposal
  gets accepted.

- the I2C node uses the property clock-frequency to define the desired
  I2C bus frequency. If 0, the FDR/DFSRR register already set by the
  bootloader will not be touched.

- I use Timur's divider table approach from U-Boot as it's more
  efficient than an appropriate algorithm (less code).

- If none of the above new properties are defined, the old hard-coded
  FDR/DFSRR register settings are used for backward compatibility.

I have tested the speed settings basically on an MPC8544 and MPC5200
board. The 8xxx table may need some tweaking/conversion for the 82xx.

What do you think? I'm still not happy that the tables and lookup
function are common code. But for the 82xx/85xx/86xx it's not obvious
to me where to put it.

Note: I'm aware that this patch is not yet perfect, e.g. the documentation
of the new bindings are missing and debug messages need to be removed.

Wolfgang.

---
 drivers/i2c/busses/i2c-mpc.c |  140 +++
 1 file changed, 128 insertions(+), 12 deletions(-)

Index: linux-2.6.29-rc7/drivers/i2c/busses/i2c-mpc.c
===
--- linux-2.6.29-rc7.orig/drivers/i2c/busses/i2c-mpc.c
+++ linux-2.6.29-rc7/drivers/i2c/busses/i2c-mpc.c
@@ -58,6 +58,11 @@ struct mpc_i2c {
u32 flags;
 };
 
+struct mpc_i2c_div {
+   u16 divider;
+   u16 fdr;/* including dfsrr */
+};
+
 static __inline__ void writeccr(struct mpc_i2c *i2c, u32 x)
 {
writeb(x, i2c-base + MPC_I2C_CR);
@@ -153,16 +158,107 @@ static int i2c_wait(struct mpc_i2c *i2c,
return 0;
 }
 
-static void mpc_i2c_setclock(struct mpc_i2c *i2c)
+static const struct mpc_i2c_div mpc_i2c_8xxx_divs[] = {
+   {160, 0x0120}, {192, 0x0121}, {224, 0x0122}, {256, 0x0123},
+   {288, 0x0100}, {320, 0x0101}, {352, 0x0601}, {384, 0x0102},
+   {416, 0x0602}, {448, 0x0126}, {480, 0x0103}, {512, 0x0127},
+   {544, 0x0b03}, {576, 0x0104}, {608, 0x1603}, {640, 0x0105},
+   {672, 0x2003}, {704, 0x0b05}, {736, 0x2b03}, {768, 0x0106},
+   {800, 0x3603}, {832, 0x0b06}, {896, 0x012a}, {960, 0x0107},
+   {1024, 0x012b}, {1088, 0x1607}, {1152, 0x0108}, {1216, 0x2b07},
+   {1280, 0x0109}, {1408, 0x1609}, {1536, 0x010a}, {1664, 0x160a},
+   {1792, 0x012e}, {1920, 0x010b}, {2048, 0x012f}, {2176, 0x2b0b},
+   {2304, 0x010c}, {2560, 0x010d}, {2816, 0x2b0d}, {3072, 0x010e},
+   {3328, 0x2b0e}, {3584, 0x0132}, {3840, 0x010f}, {4096, 0x0133},
+   {4608, 0x0110}, {5120, 0x0111}, {6144, 0x0112}, {7168, 0x0136},
+   {7680, 0x0113}, {8192, 0x0137}, {9216, 0x0114}, {10240, 0x0115},
+   {12288, 0x0116}, {14336, 0x013a}, {15360, 0x0117}, {16384, 0x013b},
+   {18432, 0x0118}, {20480, 0x0119}, {24576, 0x011a}, {28672, 0x013e},
+   {30720, 0x011b}, {32768, 0x013f}, {36864, 0x011c}, {40960, 0x011d},
+   {49152, 0x011e}, {61440, 0x011f}
+};
+
+/*
+ * Works for both, MPC5200 rev A and rev B processors. The rev B
+ * processors have 2 more bits, which are not used in the table below.
+ */
+static const struct mpc_i2c_div mpc_i2c_52xx_divs[] = {
+   {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
+   {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
+   {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
+   {56, 0x29}, {64, 0x2a}, {68, 0x07}, {72, 0x2b},
+   {80, 0x2c}, {88, 0x09}, {96, 0x2d}, {104, 0x0a},
+   {112, 0x2e}, {128, 0x2f}, {144, 0x0c}, {160, 0x30},
+   {192, 0x31}, {224, 0x32}, {240, 0x0f}, {256, 0x33},
+   {288, 0x10}, {320, 0x34}, {384, 0x35}, {448, 0x36},
+   {480, 0x13}, {512, 0x37}, {576, 0x14}, {640, 0x38},
+   {768, 0x39}, {896, 0x3a}, {960, 0x17}, {1024, 0x3b},
+   {1152, 0x18}, {1280, 0x3c}, {1536, 0x3d}, {1792, 0x3e},
+   {1920, 0x1b}, {2048, 0x3f}, {2304, 0x1c}, {2560, 0x1d},
+   {3072, 0x1e}, {3840, 0x1f}
+};
+
+static u16 mpc_i2c_get_fdr(const struct mpc_i2c_div *divs, int count,
+  u32 divider)
 {
-   /* Set clock and filters */
-   if (i2c-flags  FSL_I2C_DEV_SEPARATE_DFSRR) {
-   writeb(0x31, i2c-base + MPC_I2C_FDR);
-   writeb(0x10, i2c-base + MPC_I2C_DFSRR);
-   } else if (i2c-flags  FSL_I2C_DEV_CLOCK_5200)
-   writeb(0x3f, i2c-base + MPC_I2C_FDR);
-   else
-   writel(0x1031, i2c-base + MPC_I2C_FDR);
+   

Re: [PATCH v2 2/2] powerpc/83xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Anton Vorontsov
On Wed, Mar 18, 2009 at 06:28:00PM +0300, Anton Vorontsov wrote:
 On Wed, Mar 18, 2009 at 08:21:18AM -0500, Kumar Gala wrote:
 [...]
  arch/powerpc/platforms/83xx/mpc834x_mds.c |1 +
  arch/powerpc/platforms/83xx/mpc837x_mds.c |1 +
  arch/powerpc/platforms/83xx/mpc837x_rdb.c |1 +
  14 files changed, 398 insertions(+), 319 deletions(-)
 
  If we do this we should also fixup all the 85xx  86xx .dts

Here it goes. (The single patch is quite big, so I split it
into 83xx/85xx/86xx parts. Can glue them together for the
final resend, if you like).

Plus, now the patch set depends on
http://patchwork.ozlabs.org/patch/24624/

Thanks!

-- 
Anton Vorontsov
email: cbouatmai...@gmail.com
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH v3 1/4] powerpc/83xx: Add power management support for MPC837x boards

2009-03-18 Thread Anton Vorontsov
This patch adds pmc nodes to the device tree files so that the boards
will able to use standby capability of MPC837x processors. The MPC837x
PMC controllers are compatible with MPC8349 ones (i.e. no deep sleep).

sleep =  properties are used to specify SCCR masks as described
in Specifying Device Power Management Information (sleep property)
chapter in Documentation/powerpc/booting-without-of.txt.

Since I2C1 and eSDHC controllers share the same clock source, they
are now placed under sleep-nexus nodes.

A processor is able to wakeup the boards on LAN events (Wake-On-Lan),
console events (with no_console_suspend kernel command line), GPIO
events and external IRQs (IRQ1 and IRQ2).

The processor can also wakeup the boards by the fourth general purpose
timer in GTM1 block, but the GTM wakeup support isn't yet implemented
(it's tested to work, but it's unclear how can we use the quite short
GTM timers, and how do we want to expose the GTM to userspace).

Signed-off-by: Anton Vorontsov avoront...@ru.mvista.com
---
 arch/powerpc/boot/dts/mpc8377_mds.dts |   68 ---
 arch/powerpc/boot/dts/mpc8377_rdb.dts |   98 +
 arch/powerpc/boot/dts/mpc8378_mds.dts |   66 +++---
 arch/powerpc/boot/dts/mpc8378_rdb.dts |   96 
 arch/powerpc/boot/dts/mpc8379_mds.dts |   68 ---
 arch/powerpc/boot/dts/mpc8379_rdb.dts |   98 +
 6 files changed, 323 insertions(+), 171 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8377_mds.dts 
b/arch/powerpc/boot/dts/mpc8377_mds.dts
index 3e3ec8f..cebfc50 100644
--- a/arch/powerpc/boot/dts/mpc8377_mds.dts
+++ b/arch/powerpc/boot/dts/mpc8377_mds.dts
@@ -129,21 +129,38 @@
reg = 0x200 0x100;
};
 
-   i...@3000 {
+   sleep-nexus {
#address-cells = 1;
-   #size-cells = 0;
-   cell-index = 0;
-   compatible = fsl-i2c;
-   reg = 0x3000 0x100;
-   interrupts = 14 0x8;
-   interrupt-parent = ipic;
-   dfsrr;
+   #size-cells = 1;
+   compatible = simple-bus;
+   sleep = pmc 0x0c00;
+   ranges;
 
-   r...@68 {
-   compatible = dallas,ds1374;
-   reg = 0x68;
-   interrupts = 19 0x8;
+   i...@3000 {
+   #address-cells = 1;
+   #size-cells = 0;
+   cell-index = 0;
+   compatible = fsl-i2c;
+   reg = 0x3000 0x100;
+   interrupts = 14 0x8;
interrupt-parent = ipic;
+   dfsrr;
+
+   r...@68 {
+   compatible = dallas,ds1374;
+   reg = 0x68;
+   interrupts = 19 0x8;
+   interrupt-parent = ipic;
+   };
+   };
+
+   sd...@2e000 {
+   compatible = fsl,mpc8377-esdhc, 
fsl,mpc8379-esdhc;
+   reg = 0x2e000 0x1000;
+   interrupts = 42 0x8;
+   interrupt-parent = ipic;
+   /* Filled in by U-Boot */
+   clock-frequency = 0;
};
};
 
@@ -176,6 +193,7 @@
interrupts = 38 0x8;
dr_mode = host;
phy_type = ulpi;
+   sleep = pmc 0x00c0;
};
 
m...@24520 {
@@ -226,6 +244,8 @@
interrupt-parent = ipic;
tbi-handle = tbi0;
phy-handle = phy2;
+   sleep = pmc 0xc000;
+   fsl,magic-packet;
};
 
enet1: ether...@25000 {
@@ -240,6 +260,8 @@
interrupt-parent = ipic;
tbi-handle = tbi1;
phy-handle = phy3;
+   sleep = pmc 0x3000;
+   fsl,magic-packet;
};
 
serial0: ser...@4500 {
@@ -311,15 +333,7 @@
fsl,channel-fifo-len = 24;
fsl,exec-units-mask = 0x9fe;
fsl,descriptor-types-mask = 0x3ab0ebf;
-   };
-
-   sd...@2e000 {
-   compatible = fsl,mpc8377-esdhc, fsl,mpc8379-esdhc;
-

[PATCH v3 2/4] powerpc/83xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Anton Vorontsov
Currently it doesn't matter where the mdio nodes are placed, but with
power management support (i.e. when sleep =  properties will take
effect), mdio nodes placement will become important: mdio controller
is a part of the ethernet block, so the mdio nodes should be placed
correctly. Otherwise we may wrongly assume that MDIO controllers are
available during sleep.

Suggested-by: Scott Wood scottw...@freescale.com
Signed-off-by: Anton Vorontsov avoront...@ru.mvista.com
---
 arch/powerpc/boot/dts/asp834x-redboot.dts |   82 +++-
 arch/powerpc/boot/dts/mpc8315erdb.dts |   80 +++-
 arch/powerpc/boot/dts/mpc8349emitx.dts|   69 +---
 arch/powerpc/boot/dts/mpc8349emitxgp.dts  |   42 ---
 arch/powerpc/boot/dts/mpc834x_mds.dts |   81 +++-
 arch/powerpc/boot/dts/mpc8377_mds.dts |   80 +++-
 arch/powerpc/boot/dts/mpc8377_rdb.dts |   67 +---
 arch/powerpc/boot/dts/mpc8378_mds.dts |   80 +++-
 arch/powerpc/boot/dts/mpc8378_rdb.dts |   69 ++---
 arch/powerpc/boot/dts/mpc8379_mds.dts |   79 +++
 arch/powerpc/boot/dts/mpc8379_rdb.dts |   66 +--
 arch/powerpc/boot/dts/sbc8349.dts |   80 +++-
 arch/powerpc/platforms/83xx/asp834x.c |1 +
 arch/powerpc/platforms/83xx/mpc834x_itx.c |1 +
 arch/powerpc/platforms/83xx/mpc834x_mds.c |1 +
 arch/powerpc/platforms/83xx/mpc837x_mds.c |1 +
 arch/powerpc/platforms/83xx/mpc837x_rdb.c |1 +
 arch/powerpc/platforms/83xx/sbc834x.c |1 +
 18 files changed, 488 insertions(+), 393 deletions(-)

diff --git a/arch/powerpc/boot/dts/asp834x-redboot.dts 
b/arch/powerpc/boot/dts/asp834x-redboot.dts
index 524af7e..7da84fd 100644
--- a/arch/powerpc/boot/dts/asp834x-redboot.dts
+++ b/arch/powerpc/boot/dts/asp834x-redboot.dts
@@ -181,70 +181,76 @@
phy_type = ulpi;
};
 
-   m...@24520 {
-   #address-cells = 1;
-   #size-cells = 0;
-   compatible = fsl,gianfar-mdio;
-   reg = 0x24520 0x20;
-
-   phy0: ethernet-...@0 {
-   interrupt-parent = ipic;
-   interrupts = 17 0x8;
-   reg = 0x1;
-   device_type = ethernet-phy;
-   };
-   phy1: ethernet-...@1 {
-   interrupt-parent = ipic;
-   interrupts = 18 0x8;
-   reg = 0x2;
-   device_type = ethernet-phy;
-   };
-
-   tbi0: tbi-...@11 {
-   reg = 0x11;
-   device_type = tbi-phy;
-   };
-   };
-
-   m...@25520 {
-   #address-cells = 1;
-   #size-cells = 0;
-   compatible = fsl,gianfar-tbi;
-   reg = 0x25520 0x20;
-
-   tbi1: tbi-...@11 {
-   reg = 0x11;
-   device_type = tbi-phy;
-   };
-   };
-
-
enet0: ether...@24000 {
+   #address-cells = 1;
+   #size-cells = 1;
cell-index = 0;
device_type = network;
model = TSEC;
compatible = gianfar;
reg = 0x24000 0x1000;
+   ranges = 0x0 0x24000 0x1000;
local-mac-address = [ 00 08 e5 11 32 33 ];
interrupts = 32 0x8 33 0x8 34 0x8;
interrupt-parent = ipic;
tbi-handle = tbi0;
phy-handle = phy0;
linux,network-index = 0;
+
+   m...@520 {
+   #address-cells = 1;
+   #size-cells = 0;
+   compatible = fsl,gianfar-mdio;
+   reg = 0x520 0x20;
+
+   phy0: ethernet-...@0 {
+   interrupt-parent = ipic;
+   interrupts = 17 0x8;
+   reg = 0x1;
+   device_type = ethernet-phy;
+   };
+
+   phy1: ethernet-...@1 {
+   interrupt-parent = ipic;
+   interrupts = 18 0x8;
+   reg = 0x2;
+

[PATCH v3 4/4] powerpc/86xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Anton Vorontsov
Currently it doesn't matter where the mdio nodes are placed, but with
power management support (i.e. when sleep =  properties will take
effect), mdio nodes placement will become important: mdio controller
is a part of the ethernet block, so the mdio nodes should be placed
correctly. Otherwise we may wrongly assume that MDIO controllers are
available during sleep.

Suggested-by: Scott Wood scottw...@freescale.com
Suggested-by: Kumar Gala ga...@kernel.crashing.org
Signed-off-by: Anton Vorontsov avoront...@ru.mvista.com
---
 arch/powerpc/boot/dts/gef_sbc310.dts   |   39 ---
 arch/powerpc/boot/dts/gef_sbc610.dts   |   39 ---
 arch/powerpc/boot/dts/mpc8641_hpcn.dts |  157 +++-
 arch/powerpc/boot/dts/sbc8641d.dts |  156 +++-
 arch/powerpc/platforms/86xx/gef_sbc310.c   |1 +
 arch/powerpc/platforms/86xx/gef_sbc610.c   |1 +
 arch/powerpc/platforms/86xx/mpc8610_hpcd.c |1 +
 arch/powerpc/platforms/86xx/mpc86xx_hpcn.c |1 +
 arch/powerpc/platforms/86xx/sbc8641d.c |1 +
 9 files changed, 215 insertions(+), 181 deletions(-)

diff --git a/arch/powerpc/boot/dts/gef_sbc310.dts 
b/arch/powerpc/boot/dts/gef_sbc310.dts
index 09eeb43..1569117 100644
--- a/arch/powerpc/boot/dts/gef_sbc310.dts
+++ b/arch/powerpc/boot/dts/gef_sbc310.dts
@@ -247,34 +247,37 @@
};
};
 
-   m...@24520 {
-   #address-cells = 1;
-   #size-cells = 0;
-   compatible = fsl,gianfar-mdio;
-   reg = 0x24520 0x20;
-
-   phy0: ethernet-...@0 {
-   interrupt-parent = gef_pic;
-   interrupts = 0x9 0x4;
-   reg = 1;
-   };
-   phy2: ethernet-...@2 {
-   interrupt-parent = gef_pic;
-   interrupts = 0x8 0x4;
-   reg = 3;
-   };
-   };
-
enet0: ether...@24000 {
+   #address-cells = 1;
+   #size-cells = 1;
device_type = network;
model = eTSEC;
compatible = gianfar;
reg = 0x24000 0x1000;
+   ranges = 0x0 0x24000 0x1000;
local-mac-address = [ 00 00 00 00 00 00 ];
interrupts = 0x1d 0x2 0x1e 0x2 0x22 0x2;
interrupt-parent = mpic;
phy-handle = phy0;
phy-connection-type = gmii;
+
+   m...@520 {
+   #address-cells = 1;
+   #size-cells = 0;
+   compatible = fsl,gianfar-mdio;
+   reg = 0x520 0x20;
+
+   phy0: ethernet-...@0 {
+   interrupt-parent = gef_pic;
+   interrupts = 0x9 0x4;
+   reg = 1;
+   };
+   phy2: ethernet-...@2 {
+   interrupt-parent = gef_pic;
+   interrupts = 0x8 0x4;
+   reg = 3;
+   };
+   };
};
 
enet1: ether...@26000 {
diff --git a/arch/powerpc/boot/dts/gef_sbc610.dts 
b/arch/powerpc/boot/dts/gef_sbc610.dts
index 714175c..6582dbd 100644
--- a/arch/powerpc/boot/dts/gef_sbc610.dts
+++ b/arch/powerpc/boot/dts/gef_sbc610.dts
@@ -202,34 +202,37 @@
};
};
 
-   m...@24520 {
-   #address-cells = 1;
-   #size-cells = 0;
-   compatible = fsl,gianfar-mdio;
-   reg = 0x24520 0x20;
-
-   phy0: ethernet-...@0 {
-   interrupt-parent = gef_pic;
-   interrupts = 0x9 0x4;
-   reg = 1;
-   };
-   phy2: ethernet-...@2 {
-   interrupt-parent = gef_pic;
-   interrupts = 0x8 0x4;
-   reg = 3;
-   };
-   };
-
enet0: ether...@24000 {
+   #address-cells = 1;
+   #size-cells = 1;
device_type = network;
model = eTSEC;
compatible = gianfar;
reg = 0x24000 0x1000;
+   ranges = 0x0 0x24000 0x1000;
local-mac-address = [ 00 00 00 00 00 00 ];

Re: [PATCH v3 3/4] powerpc/85xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Scott Wood

Anton Vorontsov wrote:

Currently it doesn't matter where the mdio nodes are placed, but with
power management support (i.e. when sleep =  properties will take
effect), mdio nodes placement will become important: mdio controller
is a part of the ethernet block, so the mdio nodes should be placed
correctly. Otherwise we may wrongly assume that MDIO controllers are
available during sleep.

NOTE: mpc8572ds_camp_core1.dts now fully specifies ether...@24000
layout. ether...@24000 node is disabled via status = disabled on
core1 property.


Hmm, would that imply that the mdio underneath it is disabled as well?

And are we just ignoring the possibility of races between multiple 
partitions accessing the shared mdio block?


-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 3/4] powerpc/85xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Anton Vorontsov
On Wed, Mar 18, 2009 at 03:05:51PM -0500, Scott Wood wrote:
 Anton Vorontsov wrote:
 Currently it doesn't matter where the mdio nodes are placed, but with
 power management support (i.e. when sleep =  properties will take
 effect), mdio nodes placement will become important: mdio controller
 is a part of the ethernet block, so the mdio nodes should be placed
 correctly. Otherwise we may wrongly assume that MDIO controllers are
 available during sleep.

 NOTE: mpc8572ds_camp_core1.dts now fully specifies ether...@24000
 layout. ether...@24000 node is disabled via status = disabled on
 core1 property.

 Hmm, would that imply that the mdio underneath it is disabled as well?

Technically, yes. In practice, MDIO and MAC drivers are probed
separately.

I don't see any better solution, should I just leave the core1's
mdio node intact?

 And are we just ignoring the possibility of races between multiple  
 partitions accessing the shared mdio block?

Dunno. From simply looking into the device tree, I'd assume
the same.

Thanks,

-- 
Anton Vorontsov
email: cbouatmai...@gmail.com
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 3/4] powerpc/85xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Scott Wood

Anton Vorontsov wrote:

On Wed, Mar 18, 2009 at 03:05:51PM -0500, Scott Wood wrote:

Hmm, would that imply that the mdio underneath it is disabled as well?


Technically, yes. In practice, MDIO and MAC drivers are probed
separately.


Currently, yes, but that may not always be the case.


I don't see any better solution, should I just leave the core1's
mdio node intact?


Probably.  It's not as if core1 is going to be putting ether...@24000 to 
sleep.


-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 3/4] powerpc/85xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Anton Vorontsov
On Wed, Mar 18, 2009 at 11:23:44PM +0300, Anton Vorontsov wrote:
 On Wed, Mar 18, 2009 at 03:05:51PM -0500, Scott Wood wrote:
  Anton Vorontsov wrote:
  Currently it doesn't matter where the mdio nodes are placed, but with
  power management support (i.e. when sleep =  properties will take
  effect), mdio nodes placement will become important: mdio controller
  is a part of the ethernet block, so the mdio nodes should be placed
  correctly. Otherwise we may wrongly assume that MDIO controllers are
  available during sleep.
 
  NOTE: mpc8572ds_camp_core1.dts now fully specifies ether...@24000
  layout. ether...@24000 node is disabled via status = disabled on
  core1 property.
 
  Hmm, would that imply that the mdio underneath it is disabled as well?
 
 Technically, yes. In practice, MDIO and MAC drivers are probed
 separately.
 
 I don't see any better solution, should I just leave the core1's
 mdio node intact?

Ah. We also could change compatible entry to fsl,gianfar-slave.
This will prevent gianfar MAC driver to probe on core1.

-- 
Anton Vorontsov
email: cbouatmai...@gmail.com
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 3/4] powerpc/85xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Scott Wood

Anton Vorontsov wrote:

On Wed, Mar 18, 2009 at 11:23:44PM +0300, Anton Vorontsov wrote:

I don't see any better solution, should I just leave the core1's
mdio node intact?


Ah. We also could change compatible entry to fsl,gianfar-slave.
This will prevent gianfar MAC driver to probe on core1.


...and also prevent it from probing the children, unless simple-bus is 
specified, or Linux is given special knowledge of the 
fsl,gianfar-slave name.


-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 3/4] powerpc/85xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Anton Vorontsov
On Wed, Mar 18, 2009 at 03:31:29PM -0500, Scott Wood wrote:
 Anton Vorontsov wrote:
 On Wed, Mar 18, 2009 at 11:23:44PM +0300, Anton Vorontsov wrote:
 I don't see any better solution, should I just leave the core1's
 mdio node intact?

 Ah. We also could change compatible entry to fsl,gianfar-slave.
 This will prevent gianfar MAC driver to probe on core1.

 ...and also prevent it from probing the children, unless simple-bus is  
 specified, or Linux is given special knowledge of the  
 fsl,gianfar-slave name.

Yup. Do you see any problem with this?

-- 
Anton Vorontsov
email: cbouatmai...@gmail.com
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 3/4] powerpc/85xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Scott Wood

Anton Vorontsov wrote:

On Wed, Mar 18, 2009 at 03:31:29PM -0500, Scott Wood wrote:

Anton Vorontsov wrote:

On Wed, Mar 18, 2009 at 11:23:44PM +0300, Anton Vorontsov wrote:

I don't see any better solution, should I just leave the core1's
mdio node intact?

Ah. We also could change compatible entry to fsl,gianfar-slave.
This will prevent gianfar MAC driver to probe on core1.
...and also prevent it from probing the children, unless simple-bus is  
specified, or Linux is given special knowledge of the  
fsl,gianfar-slave name.


Yup. Do you see any problem with this?


Yes, the mdio node would not get probed.  Why put it in the device tree 
at all then?


-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 3/4] powerpc/85xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Anton Vorontsov
On Wed, Mar 18, 2009 at 03:35:11PM -0500, Scott Wood wrote:
 Anton Vorontsov wrote:
 On Wed, Mar 18, 2009 at 03:31:29PM -0500, Scott Wood wrote:
 Anton Vorontsov wrote:
 On Wed, Mar 18, 2009 at 11:23:44PM +0300, Anton Vorontsov wrote:
 I don't see any better solution, should I just leave the core1's
 mdio node intact?
 Ah. We also could change compatible entry to fsl,gianfar-slave.
 This will prevent gianfar MAC driver to probe on core1.
 ...and also prevent it from probing the children, unless simple-bus 
 is  specified, or Linux is given special knowledge of the   
 fsl,gianfar-slave name.

 Yup. Do you see any problem with this?

 Yes, the mdio node would not get probed.  Why put it in the device tree  
 at all then?

I mean do you see any problem with giving Linux knowledge of
the -slave name?

p.s.

Actually, we can stay with status = .. property, and if
things ever change, it's always driver's duty to check for
of_device_is_available(), and so the driver can simply check
for
if (!strcmp(status, disabled on core))
probe_children_only().

-- 
Anton Vorontsov
email: cbouatmai...@gmail.com
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 3/4] powerpc/85xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Scott Wood

Anton Vorontsov wrote:

I mean do you see any problem with giving Linux knowledge of
the -slave name?


I guess I don't really see the point, compared with just having a naked 
mdio node.  The power management issue in this case should be addressed 
by ensuring that core0 never puts ether...@24000 to sleep.


-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v3 3/4] powerpc/85xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread Anton Vorontsov
On Wed, Mar 18, 2009 at 03:46:49PM -0500, Scott Wood wrote:
 Anton Vorontsov wrote:
 I mean do you see any problem with giving Linux knowledge of
 the -slave name?

 I guess I don't really see the point, compared with just having a naked  
 mdio node.  The power management issue in this case should be addressed  
 by ensuring that core0 never puts ether...@24000 to sleep.

Amen.

If there'll be no further issues, I'll resend the patch set tomorrow.

Thanks!

-- 
Anton Vorontsov
email: cbouatmai...@gmail.com
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: About [AMCC 460EX/canyonlands board] Synopsys DesignWare Cores (DWC) SATA host driver

2009-03-18 Thread Feng Kan

Hi RenQuan:

We are aware of the issue, currently the sata is only supported up to 
2.6.25.7. We are working on a patchable version

to submit to main line.

Thanks
Feng Kan

Cheng Renquan wrote:

Mark,
  I found that the current sata_dwc can only work on
DENX-2.6.25-stable, and have problems in DENX-2.6.26, 27, 28,
29(master),
the boot errors is as the following, I hope you and AMCC staff submit
it into mainline soon, thanks.

there is also some other boot panic kmsg, I will reproduce it tomorrow.

http://git.denx.de/linux-2.6-denx.git/

Synopsys DesignWare Cores (DWC) SATA host driver

linuxppc-dev@ozlabs.org

About AMCC DesignWare Core SATA controller driver:

= boot
Using ip address 172.16.90.27
## Booting kernel from Legacy Image at ff60 ...
   Image Name:   Linux-2.6.27.19
   Created:  2009-03-13  10:18:17 UTC
   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
   Data Size:1574261 Bytes =  1.5 MB
   Load Address: 
   Entry Point:  
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
## Flattened Device Tree blob at fc1e
   Booting using the fdt blob at 0xfc1e
## Loading init Ramdisk from Legacy Image at fc20 ...
   Image Name:   canyonlands ramdisk rev. 001
   Created:  2008-05-13  11:18:24 UTC
   Image Type:   PowerPC Linux RAMDisk Image (gzip compressed)
   Data Size:18968362 Bytes = 18.1 MB
   Load Address: 
   Entry Point:  
   Verifying Checksum ... OK
   Loading Device Tree to 007fa000, end 007f ... OK
   Loading Ramdisk to 1ec3d000, end 1fe53f2a ... OK
Using Canyonlands machine description
Linux version 2.6.27.19 (fed...@ubox-h1) (gcc version 4.2.2) #1 Fri
Mar 13 18:18:05 HKT 2009
Found initrd at 0xdec3d000:0xdfe53f2a
Zone PFN ranges:
  DMA  0x - 0x0002
  Normal   0x0002 - 0x0002
  HighMem  0x0002 - 0x0002


scsi 0:0:0:0: Direct-Access ATA  WDC WD10EVVS-63E 01.0 PQ: 0 ANSI: 5
sd 0:0:0:0: [sda] 1953525168 512-byte hardware sectors (1000205 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
support DPO or FUA
sd 0:0:0:0: [sda] 1953525168 512-byte hardware sectors (1000205 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
support DPO or FUA
 sda:3ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
 res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
ata1.00: status: { DRDY }
ata1: link is slow to respond, please be patient (ready=0)
ata1: prereset failed (errno=-16)
ata1: reset failed, giving up
ata1.00: disabled
ata1: EH complete
sd 0:0:0:0: [sda] Result: hostbyte=0x04 driverbyte=0x00
end_request: I/O error, dev sda, sector 0
Buffer I/O error on device sda, logical block 0
sd 0:0:0:0: [sda] Result: hostbyte=0x04 driverbyte=0x00
end_request: I/O error, dev sda, sector 0
Buffer I/O error on device sda, logical block 0
 unable to read partition table
sd 0:0:0:0: [sda] Attached SCSI disk
4cc00.nor_flash: Found 1 x16 devices at 0x0 in 16-bit bank
 Amd/Fujitsu Extended Query Table at 0x0040
4cc00.nor_flash: CFI does not contain boot bank location. Assuming top.
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
RedBoot partition parsing not available
Creating 7 MTD partitions on 4cc00.nor_flash:
0x-0x001e : kernel
0x001e-0x0020 : dtb
0x0020-0x0160 : ramdisk
0x0160-0x01a0 : jffs2
0x01a0-0x03f6 : user
0x03f6-0x03fa : env
0x03fa-0x0400 : u-boot
NDFC NAND Driver initialized. Chip-Rev: 0x0111
NAND device: Manufacturer ID: 0x20, Chip ID: 0xf1 (ST Micro NAND
128MiB 3,3V 8-bit)
Scanning device for bad blocks
Number of partitions 3
Creating 3 MTD partitions on NAND 128MiB 3,3V 8-bit:
0x-0x0010 : u-boot
0x0010-0x0014 : env
0x0014-0x0800 : content
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
dwc_otg: version 2.60a 22-NOV-2006
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
eth0: link is up, 1000 FDX, pause enabled
IP-Config: Complete:
 device=eth0, addr=172.16.90.27, mask=255.255.255.0, gw=255.255.255.255,
 host=canyonlands, domain=, nis-domain=(none),
 bootserver=172.16.90.26, rootserver=172.16.90.26, rootpath=
RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem).
Freeing unused kernel memory: 156k init
Startup utility found. Executing...
AMCC Startup utility launched.


BusyBox v1.2.1 (2008.05.13-11:11+) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ # fdisk -l
sd 0:0:0:0: [sda] Result: hostbyte=0x04 driverbyte=0x00
end_request: I/O error, dev sda, sector 8
Buffer I/O error on device 

Re: [PATCH v3 1/2] powerpc/86xx: Board support for GE Fanuc's PPC9A

2009-03-18 Thread David Gibson
On Wed, Mar 18, 2009 at 12:29:15PM +, Martyn Welch wrote:
 Support for the PPC9A VME Single Board Computer from GE Fanuc (PowerPC
 MPC8641D).
 
 This is the basic board support for GE Fanuc's PPC9A, a 6U single board
 computer, based on Freescale's MPC8641D.

One tiny nit left..

[snip]
 + fl...@1,0 {
 + compatible = gef, ppc9a-paged-flash, cfi-flash;

The space in the compatible string is probably not a good idea.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH v2 2/2] powerpc/83xx: Move gianfar mdio nodes under the ethernet nodes

2009-03-18 Thread David Gibson
On Wed, Mar 18, 2009 at 10:43:07AM -0500, Scott Wood wrote:
 On Wed, Mar 18, 2009 at 06:28:00PM +0300, Anton Vorontsov wrote:
  It would be great to have #include gianfar_enet.dts facility in .dts
  files. ;-) I heard some rumors about this, what was the consequence?..
 
 You can already do a raw include, but in most cases it needs parameterized
 templates/macros to make it useful.  There were some patches floating around
 for that, but there was some disagreement about syntax and the discussion
 seems to have died out.

Yeah - basically Jon got busy with other things, so we no longer had
critical mass to keep things moving.  I have an idea for a partway
step that will be enough for at least some applications without making
life awkward for a more complete approach later.  Basically the idea
is just to have weak property assignments - you can have an include
file which has a bunch of these, but they can be silently overriden by
normal property assignments afterwards.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: About [AMCC 460EX/canyonlands board] Synopsys DesignWare Cores (DWC) SATA host driver

2009-03-18 Thread Cheng Renquan
On Thu, Mar 19, 2009 at 6:21 AM, Feng Kan f...@amcc.com wrote:
 Hi RenQuan:

 We are aware of the issue, currently the sata is only supported up to
 2.6.25.7. We are working on a patchable version
 to submit to main line.

Well, we want some new kernel features on amcc borads,
(squashfs/ubifs/layered fs/..) those are only in newer mainline
kernels, so please respond soon, thanks.

BTW, the author declared in drivers/ata/sata_dwc.c Mark Miesfeld
mmiesf...@amcc.com seems not receive mail permanently, pruned here,
and please consider change another maintainer of that file.


 Thanks
 Feng Kan

Besides, here's some kernel panic message on 2.6.28.7,

NIP: c0195a18 LR: c01807a8 CTR: c01959ec
REGS: df82bb60 TRAP: 0300   Not tainted  (2.6.28.7-dirty)
MSR: 00029000 EE,ME  CR: 44008048  XER: 
DEAR: 0008, ESR: 
TASK = df82c000[1] 'swapper' THREAD: df82a000
GPR00: c01807a8 df82bc10 df82c000 df92d588 0002 df92d59c 4ebc7fe3 0001
GPR08: 4ebc7fe3  c032f0b4 0008 24008042 1005543c 1ffb1100 
GPR16: 1000bd80 1000bda8  c036  c02c5934 c02c5918 c032f774
GPR24: c02c4ed0  df874950 df874950 0002 df92d59c 0002 df92d588
NIP [c0195a18] sata_dwc_scr_read+0x2c/0x88
LR [c01807a8] sata_scr_read+0x7c/0x90
Call Trace:
[df82bc10] [c0179664] scsi_sysfs_add_host+0x94/0xac (unreliable)
[df82bc20] [c01807a8] sata_scr_read+0x7c/0x90
[df82bc40] [c01807dc] sata_link_init_spd+0x20/0x238
[df82bc80] [c01851e4] ata_host_register+0x174/0x2e0
[df82bcc0] [c0185404] ata_host_activate+0xb4/0x124
[df82bcf0] [c0196974] sata_dwc_probe+0x334/0x52c
[df82bd60] [c0162f78] platform_drv_probe+0x20/0x30
[df82bd70] [c0161de0] driver_probe_device+0xb8/0x1e8
[df82bd90] [c0161fb4] __driver_attach+0xa4/0xa8
[df82bdb0] [c01612e4] bus_for_each_dev+0x5c/0x98
[df82bde0] [c0161be8] driver_attach+0x24/0x34
[df82bdf0] [c0161934] bus_add_driver+0x1d8/0x258
[df82be20] [c01621c4] driver_register+0x5c/0x158
[df82be40] [c01631d4] platform_driver_register+0xac/0xbc
[df82be50] [c030c0c0] sata_dwc_init+0x18/0x28
[df82be60] [c00013dc] do_one_initcall+0x38/0x19c
[df82bfd0] [c02f3168] kernel_init+0x88/0xf4
[df82bff0] [c000d5e4] kernel_thread+0x4c/0x68
Instruction dump:
4e800020 2b840004 9421fff0 7c0802a6 bfc10008 90010014 7c9e2378 7c7f1b78
419d0038 81230060 548b103a 7c0004ac 7c095c2c 0c00 4c00012c 9005
---[ end trace e066981a4cd0462b ]---
Kernel panic - not syncing: Attempted to kill init!
Rebooting in 1 seconds..

-- 
Cheng Renquan (程任全), from Shenzhen, China
Samuel Beckett  - Birth was the death of him.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: Confused about CLOCK_TICK_RATE

2009-03-18 Thread Paul Mackerras
Timur Tabi writes:

 Can someone explain CLOCK_TICK_RATE to me?  It's defined in
 arch/powerpc/include/asm/timex.h as such:
 
 #define CLOCK_TICK_RATE   1024000 /* Underlying HZ */
 
 Every architecture defines this, but some use the better comment
 Underlying frequency of the HZ timer.
 
 My question is: why is this a constant? Shouldn't it be a variable,
 perhaps something that is based on tb_ticks_per_usec?

It's used essentially for making small adjustments to ACTHZ and
TICK_NSEC in include/linux/jiffies.h.  The value was chosen so that
ACTHZ == HZ and TICK_NSEC = 1e9 for all common HZ values, since we
can't say at compile time what the decrementer frequency will be.
I believe it's all pretty moot since we changed over to using the
generic time framework anyway.

Paul.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH] powerpc/pmi: irq handlers return irqreturn_t

2009-03-18 Thread Stephen Rothwell
Commit bedd30d986a05e32dc3eab874e4b9ed8a38058bb (genirq: make irqreturn_t
an enum) from the genirq tree in next-20090319 caused this new warning:

arch/powerpc/sysdev/pmi.c: In function 'pmi_of_probe':
arch/powerpc/sysdev/pmi.c:166: warning: passing argument 2 of 'request_irq' 
from incompatible pointer type

Change the return type of the handler from int to irqreturn_t.

Cc: Thomas Gleixner t...@linutronix.de
Cc: Peter Zijlstra pet...@infradead.org
Signed-off-by: Stephen Rothwell s...@canb.auug.org.au
---
 arch/powerpc/sysdev/pmi.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/sysdev/pmi.c b/arch/powerpc/sysdev/pmi.c
index c858749..aaa9159 100644
--- a/arch/powerpc/sysdev/pmi.c
+++ b/arch/powerpc/sysdev/pmi.c
@@ -50,7 +50,7 @@ struct pmi_data {
 
 static struct pmi_data *data;
 
-static int pmi_irq_handler(int irq, void *dev_id)
+static irqreturn_t pmi_irq_handler(int irq, void *dev_id)
 {
u8 type;
int rc;
-- 
1.6.2.1

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH] powerpc/cpm2: fix building fs_enet driver as a module.

2009-03-18 Thread Grant Likely
From: Grant Likely grant.lik...@secretlab.ca

Building the fs_enet driver as a modules fails because it cannot
access the global cpm2_immr symbol.

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

Hey Ben and Kumar,

Just found this while testing some unrelated changes.  Technically
this is a bug fix that should go into 2.6.29, but it looks like an
old problem and probably nobody is getting bitten by it.  I don't
think the world is going to end if it misses the 2.6.29 release.

g.

 arch/powerpc/sysdev/cpm2.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)


diff --git a/arch/powerpc/sysdev/cpm2.c b/arch/powerpc/sysdev/cpm2.c
index f1c3395..021480e 100644
--- a/arch/powerpc/sysdev/cpm2.c
+++ b/arch/powerpc/sysdev/cpm2.c
@@ -52,6 +52,7 @@ cpm_cpm2_t __iomem *cpmp; /* Pointer to comm processor space 
*/
  * the communication processor devices.
  */
 cpm2_map_t __iomem *cpm2_immr;
+EXPORT_SYMBOL(cpm2_immr);
 
 #define CPM_MAP_SIZE   (0x4)   /* 256k - the PQ3 reserve this amount
   of space for CPM as it is larger

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 5/5] net: make mpc5200 fec driver use of_mdio infrastructure

2009-03-18 Thread Grant Likely
On Tue, Mar 10, 2009 at 2:29 PM, Anton Vorontsov
avoront...@ru.mvista.com wrote:
 On Tue, Mar 10, 2009 at 01:48:26PM -0600, Grant Likely wrote:
 Regardless, I
 think all the drivers should be using common code for obtaining the
 phy_device from the device tree.

 Not necessary `struct phy_device'. All we need is some common
 routine for translating PHY's mdio_node-full_name + phy id to
 phy_bus_id.

This only works if the network driver knows how the MDIO bus is named.
 The current code assumes that the MDIO bus name is the register
address, but this is a driver implementation detail and MDIO bus
drivers can deviate from this.  What about MDIO busses that don't have
a reg property?  For example, fs_enet/mii-bitbang.c sets the bus name
to CPM2 Bitbanged MII.  There is no one-size-fits-all way to figure
out the phy bus id from the ethernet driver side of things.

The sure and simple way to guarantee a match between the PHY device
node and the phy_device is to use the PHY device_node pointer itself
as the search key.

I concede that my first attempt at this was overly complex, but I've
reworked the code and I think it makes thinks considerably simpler.
I'll post a new series tomorrow.  I've got patches to make the
ucc_eth, gianfar and fs_enet drivers to use the device_node method
also.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 1/9] of: add of_parse_phandle() helper for parsing phandle properties

2009-03-18 Thread Grant Likely
From: Grant Likely grant.lik...@secretlab.ca

of_parse_phandle() is a helper function to read and parse a phandle
property and return a pointer to the resulting device_node.

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 drivers/of/base.c  |   23 +++
 include/linux/of.h |3 +++
 2 files changed, 26 insertions(+), 0 deletions(-)


diff --git a/drivers/of/base.c b/drivers/of/base.c
index cd17092..1eaada4 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -494,6 +494,29 @@ int of_modalias_node(struct device_node *node, char 
*modalias, int len)
 EXPORT_SYMBOL_GPL(of_modalias_node);
 
 /**
+ * of_parse_phandle - Resolve a phandle property to a device_node pointer
+ * @np: Pointer to device node holding phandle property
+ * @phandle_name: Name of property holding a phandle value
+ * @index: For properties holding a table of phandles, this is the index into
+ * the table
+ *
+ * Returns the device_node pointer pointed to by the phandle, or NULL
+ */
+struct device_node *
+of_parse_phandle(struct device_node *np, const char *phandle_name, int index)
+{
+   const phandle *phandle;
+   int size;
+
+   phandle = of_get_property(np, phandle_name, size);
+   if ((!phandle) || (size  sizeof(*phandle) * (index + 1)))
+   return NULL;
+
+   return of_find_node_by_phandle(phandle[index]);
+}
+EXPORT_SYMBOL(of_parse_phandle);
+
+/**
  * of_parse_phandles_with_args - Find a node pointed by phandle in a list
  * @np:pointer to a device tree node containing a list
  * @list_name: property name that contains a list
diff --git a/include/linux/of.h b/include/linux/of.h
index 6a7efa2..7be2d10 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -77,6 +77,9 @@ extern int of_n_size_cells(struct device_node *np);
 extern const struct of_device_id *of_match_node(
const struct of_device_id *matches, const struct device_node *node);
 extern int of_modalias_node(struct device_node *node, char *modalias, int len);
+extern struct device_node *of_parse_phandle(struct device_node *np,
+   const char *phandle_name,
+   int index);
 extern int of_parse_phandles_with_args(struct device_node *np,
const char *list_name, const char *cells_name, int index,
struct device_node **out_node, const void **out_args);

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 2/9] phylib: rework to prepare for OF registration of PHYs

2009-03-18 Thread Grant Likely
From: Grant Likely grant.lik...@secretlab.ca

This patch makes changes in preparation for supporting open firmware
device tree descriptions of MDIO busses.  Changes include:
- Cleanup handling of phy_map[] entries; they are already NULLed when
  registering and so don't need to be re-cleared, and it is good practice
  to clear them out when unregistering.
- Split phy_device registration out into a new function so that the
  OF helpers can do two stage registration (separate allocation and
  registration steps).

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
CC: linuxppc-dev@ozlabs.org
CC: net...@vger.kernel.org
CC: Andy Fleming aflem...@freescale.com
---

 drivers/net/phy/mdio_bus.c   |   29 +++-
 drivers/net/phy/phy_device.c |   43 ++
 include/linux/phy.h  |1 +
 3 files changed, 43 insertions(+), 30 deletions(-)


diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 811a637..3c39c7b 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -112,7 +112,6 @@ int mdiobus_register(struct mii_bus *bus)
bus-reset(bus);
 
for (i = 0; i  PHY_MAX_ADDR; i++) {
-   bus-phy_map[i] = NULL;
if ((bus-phy_mask  (1  i)) == 0) {
struct phy_device *phydev;
 
@@ -149,6 +148,7 @@ void mdiobus_unregister(struct mii_bus *bus)
for (i = 0; i  PHY_MAX_ADDR; i++) {
if (bus-phy_map[i])
device_unregister(bus-phy_map[i]-dev);
+   bus-phy_map[i] = NULL;
}
 }
 EXPORT_SYMBOL(mdiobus_unregister);
@@ -187,35 +187,12 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int 
addr)
if (IS_ERR(phydev) || phydev == NULL)
return phydev;
 
-   /* There's a PHY at this address
-* We need to set:
-* 1) IRQ
-* 2) bus_id
-* 3) parent
-* 4) bus
-* 5) mii_bus
-* And, we need to register it */
-
-   phydev-irq = bus-irq != NULL ? bus-irq[addr] : PHY_POLL;
-
-   phydev-dev.parent = bus-parent;
-   phydev-dev.bus = mdio_bus_type;
-   dev_set_name(phydev-dev, PHY_ID_FMT, bus-id, addr);
-
-   phydev-bus = bus;
-
-   /* Run all of the fixups for this PHY */
-   phy_scan_fixups(phydev);
-
-   err = device_register(phydev-dev);
+   err = phy_device_register(phydev);
if (err) {
-   printk(KERN_ERR phy %d failed to register\n, addr);
phy_device_free(phydev);
-   phydev = NULL;
+   return NULL;
}
 
-   bus-phy_map[addr] = phydev;
-
return phydev;
 }
 EXPORT_SYMBOL(mdiobus_scan);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 0a06e4f..793332f 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -39,10 +39,6 @@ MODULE_DESCRIPTION(PHY library);
 MODULE_AUTHOR(Andy Fleming);
 MODULE_LICENSE(GPL);
 
-static struct phy_driver genphy_driver;
-extern int mdio_bus_init(void);
-extern void mdio_bus_exit(void);
-
 void phy_device_free(struct phy_device *phydev)
 {
kfree(phydev);
@@ -53,6 +49,10 @@ static void phy_device_release(struct device *dev)
phy_device_free(to_phy_device(dev));
 }
 
+static struct phy_driver genphy_driver;
+extern int mdio_bus_init(void);
+extern void mdio_bus_exit(void);
+
 static LIST_HEAD(phy_fixup_list);
 static DEFINE_MUTEX(phy_fixup_lock);
 
@@ -166,6 +166,10 @@ struct phy_device* phy_device_create(struct mii_bus *bus, 
int addr, int phy_id)
dev-addr = addr;
dev-phy_id = phy_id;
dev-bus = bus;
+   dev-dev.parent = bus-parent;
+   dev-dev.bus = mdio_bus_type;
+   dev-irq = bus-irq != NULL ? bus-irq[addr] : PHY_POLL;
+   dev_set_name(dev-dev, PHY_ID_FMT, bus-id, addr);
 
dev-state = PHY_DOWN;
 
@@ -237,6 +241,37 @@ struct phy_device * get_phy_device(struct mii_bus *bus, 
int addr)
 }
 
 /**
+ * phy_device_register - Register the phy device on the MDIO bus
+ * @phy_device: phy_device structure to be added to the MDIO bus
+ */
+int phy_device_register(struct phy_device *phydev)
+{
+   int err;
+
+   /* Don't register a phy if one is already registered at this
+* address */
+   if (phydev-bus-phy_map[phydev-addr])
+   return -EINVAL;
+   phydev-bus-phy_map[phydev-addr] = phydev;
+
+   /* Run all of the fixups for this PHY */
+   phy_scan_fixups(phydev);
+
+   err = device_register(phydev-dev);
+   if (err) {
+   pr_err(phy %d failed to register\n, phydev-addr);
+   goto out;
+   }
+
+   return 0;
+
+ out:
+   phydev-bus-phy_map[phydev-addr] = NULL;
+   return err;
+}
+EXPORT_SYMBOL(phy_device_register);
+
+/**
  * phy_prepare_link - prepares the PHY layer to monitor link status
  * @phydev: target phy_device struct
  * @handler: callback function for link status change 

[PATCH 3/9] phylib: add *_direct() variants of phy_connect and phy_attach functions

2009-03-18 Thread Grant Likely
From: Grant Likely grant.lik...@secretlab.ca

Add phy_connect_direct() and phy_attach_direct() functions so that
drivers can use a pointer to the phy_device instead of trying to determine
the phy's bus_id string.

This patch is useful for OF device tree descriptions of phy devices where
the driver doesn't need or know what the bus_id value in order to get a
phy_device pointer.

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 drivers/net/phy/phy_device.c |  118 ++
 include/linux/phy.h  |5 ++
 2 files changed, 90 insertions(+), 33 deletions(-)


diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 793332f..238d21e 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -290,6 +290,33 @@ void phy_prepare_link(struct phy_device *phydev,
 }
 
 /**
+ * phy_connect_direct - connect an ethernet device to a specific phy_device
+ * @dev: the network device to connect
+ * @phydev: the pointer to the phy device
+ * @handler: callback function for state change notifications
+ * @flags: PHY device's dev_flags
+ * @interface: PHY device's interface
+ */
+int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
+  void (*handler)(struct net_device *), u32 flags,
+  phy_interface_t interface)
+{
+   int rc;
+
+   rc = phy_attach_direct(dev, phydev, flags, interface);
+   if (rc)
+   return rc;
+
+   phy_prepare_link(phydev, handler);
+   phy_start_machine(phydev, NULL);
+   if (phydev-irq  0)
+   phy_start_interrupts(phydev);
+
+   return 0;
+}
+EXPORT_SYMBOL(phy_connect_direct);
+
+/**
  * phy_connect - connect an ethernet device to a PHY device
  * @dev: the network device to connect
  * @bus_id: the id string of the PHY device to connect
@@ -310,18 +337,21 @@ struct phy_device * phy_connect(struct net_device *dev, 
const char *bus_id,
phy_interface_t interface)
 {
struct phy_device *phydev;
+   struct device *d;
+   int rc;
 
-   phydev = phy_attach(dev, bus_id, flags, interface);
-
-   if (IS_ERR(phydev))
-   return phydev;
-
-   phy_prepare_link(phydev, handler);
-
-   phy_start_machine(phydev, NULL);
+   /* Search the list of PHY devices on the mdio bus for the
+* PHY with the requested name */
+   d = bus_find_device_by_name(mdio_bus_type, NULL, bus_id);
+   if (!d) {
+   pr_err(PHY %s not found\n, bus_id);
+   return ERR_PTR(-ENODEV);
+   }
+   phydev = to_phy_device(d);
 
-   if (phydev-irq  0)
-   phy_start_interrupts(phydev);
+   rc = phy_attach_direct(dev, phydev, flags, interface);
+   if (rc)
+   return ERR_PTR(rc);
 
return phydev;
 }
@@ -345,9 +375,9 @@ void phy_disconnect(struct phy_device *phydev)
 EXPORT_SYMBOL(phy_disconnect);
 
 /**
- * phy_attach - attach a network device to a particular PHY device
+ * phy_attach_direct - attach a network device to a given PHY device pointer
  * @dev: network device to attach
- * @bus_id: PHY device to attach
+ * @phydev: Pointer to phy_device to attach
  * @flags: PHY device's dev_flags
  * @interface: PHY device's interface
  *
@@ -358,22 +388,10 @@ EXPORT_SYMBOL(phy_disconnect);
  * the attaching device, and given a callback for link status
  * change.  The phy_device is returned to the attaching driver.
  */
-struct phy_device *phy_attach(struct net_device *dev,
-   const char *bus_id, u32 flags, phy_interface_t interface)
+int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
+ u32 flags, phy_interface_t interface)
 {
-   struct bus_type *bus = mdio_bus_type;
-   struct phy_device *phydev;
-   struct device *d;
-
-   /* Search the list of PHY devices on the mdio bus for the
-* PHY with the requested name */
-   d = bus_find_device_by_name(bus, NULL, bus_id);
-   if (d) {
-   phydev = to_phy_device(d);
-   } else {
-   printk(KERN_ERR %s not found\n, bus_id);
-   return ERR_PTR(-ENODEV);
-   }
+   struct device *d = phydev-dev;
 
/* Assume that if there is no driver, that it doesn't
 * exist, and we should use the genphy driver. */
@@ -386,13 +404,12 @@ struct phy_device *phy_attach(struct net_device *dev,
err = device_bind_driver(d);
 
if (err)
-   return ERR_PTR(err);
+   return err;
}
 
if (phydev-attached_dev) {
-   printk(KERN_ERR %s: %s already attached\n,
-   dev-name, bus_id);
-   return ERR_PTR(-EBUSY);
+   dev_err(dev-dev, PHY already attached\n);
+   return -EBUSY;
}
 
phydev-attached_dev = dev;
@@ -410,13 +427,48 @@ struct phy_device 

[PATCH 4/9] openfirmware: Add OF phylib support code

2009-03-18 Thread Grant Likely
From: Grant Likely grant.lik...@secretlab.ca

Add support for parsing the device tree for PHY devices on an MDIO bus

CC: Andy Fleming aflem...@freescale.com
CC: linuxppc-dev@ozlabs.org
CC: devtree-disc...@ozlabs.org

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 drivers/of/Kconfig  |6 ++
 drivers/of/Makefile |1 
 drivers/of/of_mdio.c|  130 +++
 include/linux/of_mdio.h |   21 
 4 files changed, 158 insertions(+), 0 deletions(-)
 create mode 100644 drivers/of/of_mdio.c
 create mode 100644 include/linux/of_mdio.h


diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index f821dbc..6fe043b 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -19,3 +19,9 @@ config OF_SPI
depends on OF  PPC_OF  SPI
help
  OpenFirmware SPI accessors
+
+config OF_MDIO
+   def_tristate PHYLIB
+   depends on OF  PHYLIB
+   help
+ OpenFirmware MDIO bus (Ethernet PHY) accessors
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index 4c3c6f8..bdfb5f5 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_OF_DEVICE) += device.o platform.o
 obj-$(CONFIG_OF_GPIO)   += gpio.o
 obj-$(CONFIG_OF_I2C)   += of_i2c.o
 obj-$(CONFIG_OF_SPI)   += of_spi.o
+obj-$(CONFIG_OF_MDIO)  += of_mdio.o
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
new file mode 100644
index 000..6f3038a
--- /dev/null
+++ b/drivers/of/of_mdio.c
@@ -0,0 +1,130 @@
+/*
+ * OF helpers for the MDIO (Ethernet PHY) API
+ *
+ * Copyright (c) 2009 Secret Lab Technologies, Ltd.
+ *
+ * This file is released under the GPLv2
+ *
+ * This file provides helper functions for extracting PHY device information
+ * out of the OpenFirmware device tree and using it to populate an mii_bus.
+ */
+
+#include linux/phy.h
+#include linux/of.h
+#include linux/of_mdio.h
+#include linux/module.h
+
+MODULE_AUTHOR(Grant Likely grant.lik...@secretlab.ca);
+MODULE_LICENSE(GPL);
+
+/**
+ * of_mdiobus_register - Register mii_bus and create PHYs from the device tree
+ * @mdio: pointer to mii_bus structure
+ * @np: pointer to device_node of MDIO bus.
+ *
+ * This function registers the mii_bus structure and registers a phy_device
+ * for each child node of @np.
+ */
+int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
+{
+   struct phy_device *phy;
+   struct device_node *child;
+   int rc, i;
+
+   /* Mask out all PHYs from auto probing.  Instead the PHYs listed in
+* the device tree are populated after the bus has been registered */
+   mdio-phy_mask = ~0;
+
+   /* Clear all the IRQ properties */
+   if (mdio-irq)
+   for (i=0; iPHY_MAX_ADDR; i++)
+   mdio-irq[i] = PHY_POLL;
+
+   /* Register the MDIO bus */
+   rc = mdiobus_register(mdio);
+   if (rc)
+   return rc;
+
+   /* Loop over the child nodes and register a phy_device for each one */
+   for_each_child_of_node(np, child) {
+   const u32 *addr;
+   int len;
+
+   /* A PHY must have a reg property in the range [0-31] */
+   addr = of_get_property(child, reg, len);
+   if (!addr || len  sizeof(*addr) || *addr = 32 || *addr  0) {
+   dev_err(mdio-dev, %s has invalid PHY address\n,
+   child-full_name);
+   continue;
+   }
+
+   if (mdio-irq) {
+   mdio-irq[*addr] = irq_of_parse_and_map(child, 0);
+   if (!mdio-irq[*addr])
+   mdio-irq[*addr] = PHY_POLL;
+   }
+
+   phy = get_phy_device(mdio, *addr);
+   if (!phy) {
+   dev_err(mdio-dev, error probing PHY at address %i\n,
+   *addr);
+   continue;
+   }
+   phy_scan_fixups(phy);
+
+   /* Associate the OF node with the device structure so it
+* can be looked up later */
+   of_node_get(child);
+   dev_archdata_set_node(phy-dev.archdata, child);
+
+   /* All data is now stored in the phy struct; register it */
+   rc = phy_device_register(phy);
+   if (rc) {
+   phy_device_free(phy);
+   of_node_put(child);
+   continue;
+   }
+
+   dev_dbg(mdio-dev, registered phy %s at address %i\n,
+   child-name, *addr);
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(of_mdiobus_register);
+
+/**
+ * of_phy_connect - Connect to the phy described in the device tree
+ * @dev: pointer to net_device claiming the phy
+ * @phy_np: Pointer to device tree node for the PHY
+ * @hndlr: Link state callback for the network device
+ * @iface: PHY data interface type
+ *
+ * Returns a pointer to the 

[PATCH 5/9] net: make mpc5200 fec driver use of_mdio infrastructure

2009-03-18 Thread Grant Likely
From: Grant Likely grant.lik...@secretlab.ca

The patch reworks the MPC5200 Fast Ethernet Controller (FEC) driver to
use the of_mdio infrastructure for registering PHY devices from data out
openfirmware device tree, and eliminates the assumption that the PHY
for the FEC is always attached to the FEC's own MDIO bus.  With this
patch, the FEC can use a PHY attached to any MDIO bus if it is described
in the device tree.
---

 drivers/net/Kconfig   |2 
 drivers/net/fec_mpc52xx.c |  175 +++--
 drivers/net/fec_mpc52xx_phy.c |   26 +-
 3 files changed, 53 insertions(+), 150 deletions(-)


diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index a2f185f..3aa24f6 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1854,7 +1854,7 @@ config FEC_MPC52xx
 
 config FEC_MPC52xx_MDIO
bool MPC52xx FEC MDIO bus driver
-   depends on FEC_MPC52xx
+   depends on FEC_MPC52xx  OF_MDIO
default y
---help---
  The MPC5200's FEC can connect to the Ethernet either with
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index 3d55f9a..12ab8ae 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -25,6 +25,7 @@
 #include linux/hardirq.h
 #include linux/delay.h
 #include linux/of_device.h
+#include linux/of_mdio.h
 #include linux/of_platform.h
 
 #include linux/netdevice.h
@@ -43,11 +44,9 @@
 
 #define DRIVER_NAME mpc52xx-fec
 
-#define FEC5200_PHYADDR_NONE   (-1)
-#define FEC5200_PHYADDR_7WIRE  (-2)
-
 /* Private driver data structure */
 struct mpc52xx_fec_priv {
+   struct net_device *ndev;
int duplex;
int speed;
int r_irq;
@@ -59,10 +58,11 @@ struct mpc52xx_fec_priv {
int msg_enable;
 
/* MDIO link details */
-   int phy_addr;
-   unsigned int phy_speed;
+   unsigned int mdio_speed;
+   struct device_node *phy_node;
struct phy_device *phydev;
enum phy_state link;
+   int seven_wire_mode;
 };
 
 
@@ -210,66 +210,6 @@ static void mpc52xx_fec_adjust_link(struct net_device *dev)
phy_print_status(phydev);
 }
 
-static int mpc52xx_fec_init_phy(struct net_device *dev)
-{
-   struct mpc52xx_fec_priv *priv = netdev_priv(dev);
-   struct phy_device *phydev;
-   char phy_id[BUS_ID_SIZE];
-
-   snprintf(phy_id, sizeof(phy_id), %x:%02x,
-   (unsigned int)dev-base_addr, priv-phy_addr);
-
-   priv-link = PHY_DOWN;
-   priv-speed = 0;
-   priv-duplex = -1;
-
-   phydev = phy_connect(dev, phy_id, mpc52xx_fec_adjust_link, 0, 
PHY_INTERFACE_MODE_MII);
-   if (IS_ERR(phydev)) {
-   dev_err(dev-dev, phy_connect failed\n);
-   return PTR_ERR(phydev);
-   }
-   dev_info(dev-dev, attached phy %i to driver %s\n,
-   phydev-addr, phydev-drv-name);
-
-   priv-phydev = phydev;
-
-   return 0;
-}
-
-static int mpc52xx_fec_phy_start(struct net_device *dev)
-{
-   struct mpc52xx_fec_priv *priv = netdev_priv(dev);
-   int err;
-
-   if (priv-phy_addr  0)
-   return 0;
-
-   err = mpc52xx_fec_init_phy(dev);
-   if (err) {
-   dev_err(dev-dev, mpc52xx_fec_init_phy failed\n);
-   return err;
-   }
-
-   /* reset phy - this also wakes it from PDOWN */
-   phy_write(priv-phydev, MII_BMCR, BMCR_RESET);
-   phy_start(priv-phydev);
-
-   return 0;
-}
-
-static void mpc52xx_fec_phy_stop(struct net_device *dev)
-{
-   struct mpc52xx_fec_priv *priv = netdev_priv(dev);
-
-   if (!priv-phydev)
-   return;
-
-   phy_disconnect(priv-phydev);
-   /* power down phy */
-   phy_stop(priv-phydev);
-   phy_write(priv-phydev, MII_BMCR, BMCR_PDOWN);
-}
-
 static int mpc52xx_fec_phy_mii_ioctl(struct mpc52xx_fec_priv *priv,
struct mii_ioctl_data *mii_data, int cmd)
 {
@@ -279,25 +219,25 @@ static int mpc52xx_fec_phy_mii_ioctl(struct 
mpc52xx_fec_priv *priv,
return phy_mii_ioctl(priv-phydev, mii_data, cmd);
 }
 
-static void mpc52xx_fec_phy_hw_init(struct mpc52xx_fec_priv *priv)
-{
-   struct mpc52xx_fec __iomem *fec = priv-fec;
-
-   if (priv-phydev)
-   return;
-
-   out_be32(fec-mii_speed, priv-phy_speed);
-}
-
 static int mpc52xx_fec_open(struct net_device *dev)
 {
struct mpc52xx_fec_priv *priv = netdev_priv(dev);
int err = -EBUSY;
 
+   if (priv-phy_node) {
+   priv-phydev = of_phy_connect(priv-ndev, priv-phy_node,
+ mpc52xx_fec_adjust_link, 0, 0);
+   if (!priv-phydev) {
+   dev_err(dev-dev, of_phy_connect failed\n);
+   return -ENODEV;
+   }
+   phy_start(priv-phydev);
+   }
+
if (request_irq(dev-irq, mpc52xx_fec_interrupt, IRQF_SHARED,
DRIVER_NAME _ctrl, dev)) {

[PATCH 6/9] net/gianfar: Rework gianfar driver to use OF PHY/MDIO helper functions

2009-03-18 Thread Grant Likely
From: Grant Likely grant.lik...@secretlab.ca

This patch simplifies the driver by making use of more common code.

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 drivers/net/gianfar.c |   94 ++---
 drivers/net/gianfar.h |3 +
 drivers/net/gianfar_mii.c |   52 +
 3 files changed, 34 insertions(+), 115 deletions(-)


diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 9831b3f..0521267 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -75,6 +75,7 @@
 #include linux/if_vlan.h
 #include linux/spinlock.h
 #include linux/mm.h
+#include linux/of_mdio.h
 #include linux/of_platform.h
 #include linux/ip.h
 #include linux/tcp.h
@@ -155,17 +156,13 @@ static inline int gfar_uses_fcb(struct gfar_private *priv)
 
 static int gfar_of_init(struct net_device *dev)
 {
-   struct device_node *phy, *mdio;
-   const unsigned int *id;
const char *model;
const char *ctype;
const void *mac_addr;
-   const phandle *ph;
u64 addr, size;
int err = 0;
struct gfar_private *priv = netdev_priv(dev);
struct device_node *np = priv-node;
-   char bus_name[MII_BUS_ID_SIZE];
 
if (!np || !of_device_is_available(np))
return -ENODEV;
@@ -228,8 +225,8 @@ static int gfar_of_init(struct net_device *dev)
if (of_get_property(np, fsl,magic-packet, NULL))
priv-device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
 
-   ph = of_get_property(np, phy-handle, NULL);
-   if (ph == NULL) {
+   priv-phy_node = of_parse_phandle(np, phy-device, 0);
+   if (!priv-phy_node) {
u32 *fixed_link;
 
fixed_link = (u32 *)of_get_property(np, fixed-link, NULL);
@@ -237,57 +234,10 @@ static int gfar_of_init(struct net_device *dev)
err = -ENODEV;
goto err_out;
}
-
-   snprintf(priv-phy_bus_id, sizeof(priv-phy_bus_id),
-   PHY_ID_FMT, 0, fixed_link[0]);
-   } else {
-   phy = of_find_node_by_phandle(*ph);
-
-   if (phy == NULL) {
-   err = -ENODEV;
-   goto err_out;
-   }
-
-   mdio = of_get_parent(phy);
-
-   id = of_get_property(phy, reg, NULL);
-
-   of_node_put(phy);
-   of_node_put(mdio);
-
-   gfar_mdio_bus_name(bus_name, mdio);
-   snprintf(priv-phy_bus_id, sizeof(priv-phy_bus_id), %s:%02x,
-   bus_name, *id);
}
 
/* Find the TBI PHY.  If it's not there, we don't support SGMII */
-   ph = of_get_property(np, tbi-handle, NULL);
-   if (ph) {
-   struct device_node *tbi = of_find_node_by_phandle(*ph);
-   struct of_device *ofdev;
-   struct mii_bus *bus;
-
-   if (!tbi)
-   return 0;
-
-   mdio = of_get_parent(tbi);
-   if (!mdio)
-   return 0;
-
-   ofdev = of_find_device_by_node(mdio);
-
-   of_node_put(mdio);
-
-   id = of_get_property(tbi, reg, NULL);
-   if (!id)
-   return 0;
-
-   of_node_put(tbi);
-
-   bus = dev_get_drvdata(ofdev-dev);
-
-   priv-tbiphy = bus-phy_map[*id];
-   }
+   priv-tbi_node = of_parse_phandle(np, tbi-handle, 0);
 
return 0;
 
@@ -661,7 +611,6 @@ static int init_phy(struct net_device *dev)
uint gigabit_support =
priv-device_flags  FSL_GIANFAR_DEV_HAS_GIGABIT ?
SUPPORTED_1000baseT_Full : 0;
-   struct phy_device *phydev;
phy_interface_t interface;
 
priv-oldlink = 0;
@@ -670,23 +619,38 @@ static int init_phy(struct net_device *dev)
 
interface = gfar_get_interface(dev);
 
-   phydev = phy_connect(dev, priv-phy_bus_id, adjust_link, 0, interface);
+   if (priv-phy_node) {
+   priv-phydev = of_phy_connect(dev, priv-phy_node, adjust_link,
+ 0, interface);
+   if (!priv-phydev) {
+   dev_err(dev-dev, error: Could not attach to PHY\n);
+   return -ENODEV;
+   }
+   }
+
+   if (priv-tbi_node) {
+   priv-tbiphy = of_phy_connect(dev, priv-tbi_node, adjust_link,
+ 0, interface);
+   if (!priv-tbiphy) {
+   dev_err(dev-dev, error: Could not attach to TBI\n);
+   goto err_tbiphy;
+   }
+   }
 
if (interface == PHY_INTERFACE_MODE_SGMII)
gfar_configure_serdes(dev);
 
-   if (IS_ERR(phydev)) {
-   printk(KERN_ERR %s: Could not attach to PHY\n, dev-name);
-   return 

[PATCH 7/9] net/ucc_geth: Rework ucc_geth driver to use OF PHY/MDIO helper functions

2009-03-18 Thread Grant Likely
From: Grant Likely grant.lik...@secretlab.ca

This patch simplifies the driver by making use of more common code.

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 drivers/net/ucc_geth.c |   27 ++-
 drivers/net/ucc_geth_mii.c |   17 +++--
 2 files changed, 9 insertions(+), 35 deletions(-)


diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index e879868..45bb627 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -28,6 +28,7 @@
 #include linux/mii.h
 #include linux/phy.h
 #include linux/workqueue.h
+#include linux/of_mdio.h
 #include linux/of_platform.h
 
 #include asm/uaccess.h
@@ -1537,35 +1538,19 @@ static int init_phy(struct net_device *dev)
 {
struct ucc_geth_private *priv = netdev_priv(dev);
struct device_node *np = priv-node;
-   struct device_node *phy, *mdio;
-   const phandle *ph;
-   char bus_name[MII_BUS_ID_SIZE];
-   const unsigned int *id;
+   struct device_node *phy;
struct phy_device *phydev;
-   char phy_id[BUS_ID_SIZE];
 
priv-oldlink = 0;
priv-oldspeed = 0;
priv-oldduplex = -1;
 
-   ph = of_get_property(np, phy-handle, NULL);
-   phy = of_find_node_by_phandle(*ph);
-   mdio = of_get_parent(phy);
-
-   id = of_get_property(phy, reg, NULL);
-
+   phy = of_parse_phandle(np, phy-handle, 0);
+   phydev = of_phy_connect(dev, phy, adjust_link, 0, priv-phy_interface);
of_node_put(phy);
-   of_node_put(mdio);
-
-   uec_mdio_bus_name(bus_name, mdio);
-   snprintf(phy_id, sizeof(phy_id), %s:%02x,
-bus_name, *id);
-
-   phydev = phy_connect(dev, phy_id, adjust_link, 0, priv-phy_interface);
-
-   if (IS_ERR(phydev)) {
+   if (!phydev) {
printk(%s: Could not attach to PHY\n, dev-name);
-   return PTR_ERR(phydev);
+   return -ENODEV;
}
 
phydev-supported = (ADVERTISED_10baseT_Half |
diff --git a/drivers/net/ucc_geth_mii.c b/drivers/net/ucc_geth_mii.c
index 0ada4ed..9f2492f 100644
--- a/drivers/net/ucc_geth_mii.c
+++ b/drivers/net/ucc_geth_mii.c
@@ -36,6 +36,7 @@
 #include linux/mii.h
 #include linux/phy.h
 #include linux/fsl_devices.h
+#include linux/of_mdio.h
 #include linux/of_platform.h
 
 #include asm/io.h
@@ -135,11 +136,10 @@ static int uec_mdio_probe(struct of_device *ofdev, const 
struct of_device_id *ma
 {
struct device *device = ofdev-dev;
struct device_node *np = ofdev-node, *tempnp = NULL;
-   struct device_node *child = NULL;
struct ucc_mii_mng __iomem *regs;
struct mii_bus *new_bus;
struct resource res;
-   int k, err = 0;
+   int err = 0;
 
new_bus = mdiobus_alloc();
if (NULL == new_bus)
@@ -165,17 +165,6 @@ static int uec_mdio_probe(struct of_device *ofdev, const 
struct of_device_id *ma
goto reg_map_fail;
}
 
-   for (k = 0; k  32; k++)
-   new_bus-irq[k] = PHY_POLL;
-
-   while ((child = of_get_next_child(np, child)) != NULL) {
-   int irq = irq_of_parse_and_map(child, 0);
-   if (irq != NO_IRQ) {
-   const u32 *id = of_get_property(child, reg, NULL);
-   new_bus-irq[*id] = irq;
-   }
-   }
-
/* Set the base address */
regs = ioremap(res.start, sizeof(struct ucc_mii_mng));
 
@@ -220,7 +209,7 @@ static int uec_mdio_probe(struct of_device *ofdev, const 
struct of_device_id *ma
}
}
 
-   err = mdiobus_register(new_bus);
+   err = of_mdiobus_register(new_bus, np);
if (0 != err) {
printk(KERN_ERR %s: Cannot register as MDIO bus\n,
   new_bus-name);

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 8/9] net/pasemi_mac: Rework pasemi_mac driver to use of_mdio infrastructure

2009-03-18 Thread Grant Likely
From: Grant Likely grant.lik...@secretlab.ca

This patch simplifies the driver by making use of more common code.

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 drivers/net/pasemi_mac.c |   19 +++
 drivers/net/pasemi_mac.h |1 -
 2 files changed, 3 insertions(+), 17 deletions(-)


diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index d0349e7..8c92d1f 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -1086,34 +1086,21 @@ static int pasemi_mac_phy_init(struct net_device *dev)
struct pasemi_mac *mac = netdev_priv(dev);
struct device_node *dn, *phy_dn;
struct phy_device *phydev;
-   unsigned int phy_id;
const phandle *ph;
const unsigned int *prop;
struct resource r;
int ret;
 
dn = pci_device_to_OF_node(mac-pdev);
-   ph = of_get_property(dn, phy-handle, NULL);
-   if (!ph)
-   return -ENODEV;
-   phy_dn = of_find_node_by_phandle(*ph);
-
-   prop = of_get_property(phy_dn, reg, NULL);
-   ret = of_address_to_resource(phy_dn-parent, 0, r);
-   if (ret)
-   goto err;
-
-   phy_id = *prop;
-   snprintf(mac-phy_id, sizeof(mac-phy_id), %x:%02x,
-(int)r.start, phy_id);
-
+   phy_dn = of_parse_phandle(dn, phy-handle, 0);
of_node_put(phy_dn);
 
mac-link = 0;
mac-speed = 0;
mac-duplex = -1;
 
-   phydev = phy_connect(dev, mac-phy_id, pasemi_adjust_link, 0, 
PHY_INTERFACE_MODE_SGMII);
+   phydev = of_phy_connect(dev, phy_dn, pasemi_adjust_link, 0,
+   PHY_INTERFACE_MODE_SGMII);
 
if (IS_ERR(phydev)) {
printk(KERN_ERR %s: Could not attach to phy\n, dev-name);
diff --git a/drivers/net/pasemi_mac.h b/drivers/net/pasemi_mac.h
index 1a115ec..e2f4efa 100644
--- a/drivers/net/pasemi_mac.h
+++ b/drivers/net/pasemi_mac.h
@@ -100,7 +100,6 @@ struct pasemi_mac {
int duplex;
 
unsigned intmsg_enable;
-   charphy_id[BUS_ID_SIZE];
 };
 
 /* Software status descriptor (ring_info) */

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 9/9] net/fs_enet: Rework fs_enet driver to use of_mdio infrastructure

2009-03-18 Thread Grant Likely
From: Grant Likely grant.lik...@secretlab.ca

This patch simplifies the driver by making use of more common code.

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 drivers/net/fs_enet/fs_enet-main.c |   66 +---
 drivers/net/fs_enet/mii-bitbang.c  |   29 +---
 drivers/net/fs_enet/mii-fec.c  |   26 +-
 include/linux/fs_enet_pd.h |6 +--
 4 files changed, 14 insertions(+), 113 deletions(-)


diff --git a/drivers/net/fs_enet/fs_enet-main.c 
b/drivers/net/fs_enet/fs_enet-main.c
index ce900e5..e039d6a 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -36,6 +36,8 @@
 #include linux/fs.h
 #include linux/platform_device.h
 #include linux/phy.h
+#include linux/of.h
+#include linux/of_mdio.h
 #include linux/of_platform.h
 #include linux/of_gpio.h
 
@@ -752,9 +754,10 @@ static int fs_init_phy(struct net_device *dev)
fep-oldlink = 0;
fep-oldspeed = 0;
fep-oldduplex = -1;
-   if(fep-fpi-bus_id)
-   phydev = phy_connect(dev, fep-fpi-bus_id, fs_adjust_link, 0,
-   PHY_INTERFACE_MODE_MII);
+   if(fep-fpi-phy_node)
+   phydev = of_phy_connect(dev, fep-fpi-phy_node,
+   fs_adjust_link, 0,
+   PHY_INTERFACE_MODE_MII);
else {
printk(No phy bus ID specified in BSP code\n);
return -EINVAL;
@@ -962,57 +965,6 @@ static void cleanup_immap(void)
 
 
/**/
 
-static int __devinit find_phy(struct device_node *np,
-  struct fs_platform_info *fpi)
-{
-   struct device_node *phynode, *mdionode;
-   int ret = 0, len, bus_id;
-   const u32 *data;
-
-   data  = of_get_property(np, fixed-link, NULL);
-   if (data) {
-   snprintf(fpi-bus_id, 16, %x:%02x, 0, *data);
-   return 0;
-   }
-
-   data = of_get_property(np, phy-handle, len);
-   if (!data || len != 4)
-   return -EINVAL;
-
-   phynode = of_find_node_by_phandle(*data);
-   if (!phynode)
-   return -EINVAL;
-
-   data = of_get_property(phynode, reg, len);
-   if (!data || len != 4) {
-   ret = -EINVAL;
-   goto out_put_phy;
-   }
-
-   mdionode = of_get_parent(phynode);
-   if (!mdionode) {
-   ret = -EINVAL;
-   goto out_put_phy;
-   }
-
-   bus_id = of_get_gpio(mdionode, 0);
-   if (bus_id  0) {
-   struct resource res;
-   ret = of_address_to_resource(mdionode, 0, res);
-   if (ret)
-   goto out_put_mdio;
-   bus_id = res.start;
-   }
-
-   snprintf(fpi-bus_id, 16, %x:%02x, bus_id, *data);
-
-out_put_mdio:
-   of_node_put(mdionode);
-out_put_phy:
-   of_node_put(phynode);
-   return ret;
-}
-
 #ifdef CONFIG_FS_ENET_HAS_FEC
 #define IS_FEC(match) ((match)-data == fs_fec_ops)
 #else
@@ -1046,9 +998,9 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
fpi-rx_copybreak = 240;
fpi-use_napi = 1;
fpi-napi_weight = 17;
-
-   ret = find_phy(ofdev-node, fpi);
-   if (ret)
+   fpi-phy_node = of_parse_phandle(ofdev-node, phy-handle, 0);
+   if ((!fpi-phy_node)  (!of_get_property(ofdev-node, fixed-link,
+ NULL)))
goto out_free_fpi;
 
privsize = sizeof(*fep) +
diff --git a/drivers/net/fs_enet/mii-bitbang.c 
b/drivers/net/fs_enet/mii-bitbang.c
index 49b6645..93b481b 100644
--- a/drivers/net/fs_enet/mii-bitbang.c
+++ b/drivers/net/fs_enet/mii-bitbang.c
@@ -22,6 +22,7 @@
 #include linux/mii.h
 #include linux/platform_device.h
 #include linux/mdio-bitbang.h
+#include linux/of_mdio.h
 #include linux/of_platform.h
 
 #include fs_enet.h
@@ -149,31 +150,12 @@ static int __devinit fs_mii_bitbang_init(struct mii_bus 
*bus,
return 0;
 }
 
-static void __devinit add_phy(struct mii_bus *bus, struct device_node *np)
-{
-   const u32 *data;
-   int len, id, irq;
-
-   data = of_get_property(np, reg, len);
-   if (!data || len != 4)
-   return;
-
-   id = *data;
-   bus-phy_mask = ~(1  id);
-
-   irq = of_irq_to_resource(np, 0, NULL);
-   if (irq != NO_IRQ)
-   bus-irq[id] = irq;
-}
-
 static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
 const struct of_device_id *match)
 {
-   struct device_node *np = NULL;
struct mii_bus *new_bus;
struct bb_info *bitbang;
int ret = -ENOMEM;
-   int i;
 
bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL);
if (!bitbang)
@@ -196,17 +178,10 @@ static int __devinit fs_enet_mdio_probe(struct of_device 
*ofdev,
if 

Re: [PATCH 1/9] of: add of_parse_phandle() helper for parsing phandle properties

2009-03-18 Thread Grant Likely
Bah!  Messed up the 'stg mail' command when sending this series and
the 'RFC' tag didn't get added.

This is firmly in the RFC category.  Please don't apply.  It doesn't
have the level of polish that I'm happy with.

This series is intended to make phy_device connecting simpler and more
robust by using the PHY's device_node as the search key when
connecting to PHY.  Changes are made to both the MDIO busses to
extract the PHY data out of the device tree, and to the drivers to use
a common helper function for finding the PHY it is interested in.

Comments please.
g.

On Wed, Mar 18, 2009 at 11:00 PM, Grant Likely
grant.lik...@secretlab.ca wrote:
 From: Grant Likely grant.lik...@secretlab.ca

 of_parse_phandle() is a helper function to read and parse a phandle
 property and return a pointer to the resulting device_node.

 Signed-off-by: Grant Likely grant.lik...@secretlab.ca
 ---

  drivers/of/base.c  |   23 +++
  include/linux/of.h |    3 +++
  2 files changed, 26 insertions(+), 0 deletions(-)


 diff --git a/drivers/of/base.c b/drivers/of/base.c
 index cd17092..1eaada4 100644
 --- a/drivers/of/base.c
 +++ b/drivers/of/base.c
 @@ -494,6 +494,29 @@ int of_modalias_node(struct device_node *node, char 
 *modalias, int len)
  EXPORT_SYMBOL_GPL(of_modalias_node);

  /**
 + * of_parse_phandle - Resolve a phandle property to a device_node pointer
 + * @np: Pointer to device node holding phandle property
 + * @phandle_name: Name of property holding a phandle value
 + * @index: For properties holding a table of phandles, this is the index into
 + *         the table
 + *
 + * Returns the device_node pointer pointed to by the phandle, or NULL
 + */
 +struct device_node *
 +of_parse_phandle(struct device_node *np, const char *phandle_name, int index)
 +{
 +       const phandle *phandle;
 +       int size;
 +
 +       phandle = of_get_property(np, phandle_name, size);
 +       if ((!phandle) || (size  sizeof(*phandle) * (index + 1)))
 +               return NULL;
 +
 +       return of_find_node_by_phandle(phandle[index]);
 +}
 +EXPORT_SYMBOL(of_parse_phandle);
 +
 +/**
  * of_parse_phandles_with_args - Find a node pointed by phandle in a list
  * @np:                pointer to a device tree node containing a list
  * @list_name: property name that contains a list
 diff --git a/include/linux/of.h b/include/linux/of.h
 index 6a7efa2..7be2d10 100644
 --- a/include/linux/of.h
 +++ b/include/linux/of.h
 @@ -77,6 +77,9 @@ extern int of_n_size_cells(struct device_node *np);
  extern const struct of_device_id *of_match_node(
        const struct of_device_id *matches, const struct device_node *node);
  extern int of_modalias_node(struct device_node *node, char *modalias, int 
 len);
 +extern struct device_node *of_parse_phandle(struct device_node *np,
 +                                           const char *phandle_name,
 +                                           int index);
  extern int of_parse_phandles_with_args(struct device_node *np,
        const char *list_name, const char *cells_name, int index,
        struct device_node **out_node, const void **out_args);





-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 2/9] phylib: rework to prepare for OF registration of PHYs

2009-03-18 Thread Grant Likely
RFC, please don't apply yet.

On Wed, Mar 18, 2009 at 11:00 PM, Grant Likely
grant.lik...@secretlab.ca wrote:
 From: Grant Likely grant.lik...@secretlab.ca

 This patch makes changes in preparation for supporting open firmware
 device tree descriptions of MDIO busses.  Changes include:
 - Cleanup handling of phy_map[] entries; they are already NULLed when
  registering and so don't need to be re-cleared, and it is good practice
  to clear them out when unregistering.
 - Split phy_device registration out into a new function so that the
  OF helpers can do two stage registration (separate allocation and
  registration steps).

 Signed-off-by: Grant Likely grant.lik...@secretlab.ca
 CC: linuxppc-dev@ozlabs.org
 CC: net...@vger.kernel.org
 CC: Andy Fleming aflem...@freescale.com
 ---

  drivers/net/phy/mdio_bus.c   |   29 +++-
  drivers/net/phy/phy_device.c |   43 
 ++
  include/linux/phy.h          |    1 +
  3 files changed, 43 insertions(+), 30 deletions(-)


 diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
 index 811a637..3c39c7b 100644
 --- a/drivers/net/phy/mdio_bus.c
 +++ b/drivers/net/phy/mdio_bus.c
 @@ -112,7 +112,6 @@ int mdiobus_register(struct mii_bus *bus)
                bus-reset(bus);

        for (i = 0; i  PHY_MAX_ADDR; i++) {
 -               bus-phy_map[i] = NULL;
                if ((bus-phy_mask  (1  i)) == 0) {
                        struct phy_device *phydev;

 @@ -149,6 +148,7 @@ void mdiobus_unregister(struct mii_bus *bus)
        for (i = 0; i  PHY_MAX_ADDR; i++) {
                if (bus-phy_map[i])
                        device_unregister(bus-phy_map[i]-dev);
 +               bus-phy_map[i] = NULL;
        }
  }
  EXPORT_SYMBOL(mdiobus_unregister);
 @@ -187,35 +187,12 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, 
 int addr)
        if (IS_ERR(phydev) || phydev == NULL)
                return phydev;

 -       /* There's a PHY at this address
 -        * We need to set:
 -        * 1) IRQ
 -        * 2) bus_id
 -        * 3) parent
 -        * 4) bus
 -        * 5) mii_bus
 -        * And, we need to register it */
 -
 -       phydev-irq = bus-irq != NULL ? bus-irq[addr] : PHY_POLL;
 -
 -       phydev-dev.parent = bus-parent;
 -       phydev-dev.bus = mdio_bus_type;
 -       dev_set_name(phydev-dev, PHY_ID_FMT, bus-id, addr);
 -
 -       phydev-bus = bus;
 -
 -       /* Run all of the fixups for this PHY */
 -       phy_scan_fixups(phydev);
 -
 -       err = device_register(phydev-dev);
 +       err = phy_device_register(phydev);
        if (err) {
 -               printk(KERN_ERR phy %d failed to register\n, addr);
                phy_device_free(phydev);
 -               phydev = NULL;
 +               return NULL;
        }

 -       bus-phy_map[addr] = phydev;
 -
        return phydev;
  }
  EXPORT_SYMBOL(mdiobus_scan);
 diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
 index 0a06e4f..793332f 100644
 --- a/drivers/net/phy/phy_device.c
 +++ b/drivers/net/phy/phy_device.c
 @@ -39,10 +39,6 @@ MODULE_DESCRIPTION(PHY library);
  MODULE_AUTHOR(Andy Fleming);
  MODULE_LICENSE(GPL);

 -static struct phy_driver genphy_driver;
 -extern int mdio_bus_init(void);
 -extern void mdio_bus_exit(void);
 -
  void phy_device_free(struct phy_device *phydev)
  {
        kfree(phydev);
 @@ -53,6 +49,10 @@ static void phy_device_release(struct device *dev)
        phy_device_free(to_phy_device(dev));
  }

 +static struct phy_driver genphy_driver;
 +extern int mdio_bus_init(void);
 +extern void mdio_bus_exit(void);
 +
  static LIST_HEAD(phy_fixup_list);
  static DEFINE_MUTEX(phy_fixup_lock);

 @@ -166,6 +166,10 @@ struct phy_device* phy_device_create(struct mii_bus 
 *bus, int addr, int phy_id)
        dev-addr = addr;
        dev-phy_id = phy_id;
        dev-bus = bus;
 +       dev-dev.parent = bus-parent;
 +       dev-dev.bus = mdio_bus_type;
 +       dev-irq = bus-irq != NULL ? bus-irq[addr] : PHY_POLL;
 +       dev_set_name(dev-dev, PHY_ID_FMT, bus-id, addr);

        dev-state = PHY_DOWN;

 @@ -237,6 +241,37 @@ struct phy_device * get_phy_device(struct mii_bus *bus, 
 int addr)
  }

  /**
 + * phy_device_register - Register the phy device on the MDIO bus
 + * @phy_device: phy_device structure to be added to the MDIO bus
 + */
 +int phy_device_register(struct phy_device *phydev)
 +{
 +       int err;
 +
 +       /* Don't register a phy if one is already registered at this
 +        * address */
 +       if (phydev-bus-phy_map[phydev-addr])
 +               return -EINVAL;
 +       phydev-bus-phy_map[phydev-addr] = phydev;
 +
 +       /* Run all of the fixups for this PHY */
 +       phy_scan_fixups(phydev);
 +
 +       err = device_register(phydev-dev);
 +       if (err) {
 +               pr_err(phy %d failed to register\n, phydev-addr);
 +               goto out;
 +       }
 +
 +       return 0;
 +
 + out:
 +       phydev-bus-phy_map[phydev-addr] = NULL;
 +       return err;
 

Re: [PATCH 3/9] phylib: add *_direct() variants of phy_connect and phy_attach functions

2009-03-18 Thread Grant Likely
RFC, please don't apply yet.

On Wed, Mar 18, 2009 at 11:00 PM, Grant Likely
grant.lik...@secretlab.ca wrote:
 From: Grant Likely grant.lik...@secretlab.ca

 Add phy_connect_direct() and phy_attach_direct() functions so that
 drivers can use a pointer to the phy_device instead of trying to determine
 the phy's bus_id string.

 This patch is useful for OF device tree descriptions of phy devices where
 the driver doesn't need or know what the bus_id value in order to get a
 phy_device pointer.

 Signed-off-by: Grant Likely grant.lik...@secretlab.ca
 ---

  drivers/net/phy/phy_device.c |  118 
 ++
  include/linux/phy.h          |    5 ++
  2 files changed, 90 insertions(+), 33 deletions(-)


 diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
 index 793332f..238d21e 100644
 --- a/drivers/net/phy/phy_device.c
 +++ b/drivers/net/phy/phy_device.c
 @@ -290,6 +290,33 @@ void phy_prepare_link(struct phy_device *phydev,
  }

  /**
 + * phy_connect_direct - connect an ethernet device to a specific phy_device
 + * @dev: the network device to connect
 + * @phydev: the pointer to the phy device
 + * @handler: callback function for state change notifications
 + * @flags: PHY device's dev_flags
 + * @interface: PHY device's interface
 + */
 +int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,
 +                      void (*handler)(struct net_device *), u32 flags,
 +                      phy_interface_t interface)
 +{
 +       int rc;
 +
 +       rc = phy_attach_direct(dev, phydev, flags, interface);
 +       if (rc)
 +               return rc;
 +
 +       phy_prepare_link(phydev, handler);
 +       phy_start_machine(phydev, NULL);
 +       if (phydev-irq  0)
 +               phy_start_interrupts(phydev);
 +
 +       return 0;
 +}
 +EXPORT_SYMBOL(phy_connect_direct);
 +
 +/**
  * phy_connect - connect an ethernet device to a PHY device
  * @dev: the network device to connect
  * @bus_id: the id string of the PHY device to connect
 @@ -310,18 +337,21 @@ struct phy_device * phy_connect(struct net_device *dev, 
 const char *bus_id,
                phy_interface_t interface)
  {
        struct phy_device *phydev;
 +       struct device *d;
 +       int rc;

 -       phydev = phy_attach(dev, bus_id, flags, interface);
 -
 -       if (IS_ERR(phydev))
 -               return phydev;
 -
 -       phy_prepare_link(phydev, handler);
 -
 -       phy_start_machine(phydev, NULL);
 +       /* Search the list of PHY devices on the mdio bus for the
 +        * PHY with the requested name */
 +       d = bus_find_device_by_name(mdio_bus_type, NULL, bus_id);
 +       if (!d) {
 +               pr_err(PHY %s not found\n, bus_id);
 +               return ERR_PTR(-ENODEV);
 +       }
 +       phydev = to_phy_device(d);

 -       if (phydev-irq  0)
 -               phy_start_interrupts(phydev);
 +       rc = phy_attach_direct(dev, phydev, flags, interface);
 +       if (rc)
 +               return ERR_PTR(rc);

        return phydev;
  }
 @@ -345,9 +375,9 @@ void phy_disconnect(struct phy_device *phydev)
  EXPORT_SYMBOL(phy_disconnect);

  /**
 - * phy_attach - attach a network device to a particular PHY device
 + * phy_attach_direct - attach a network device to a given PHY device pointer
  * @dev: network device to attach
 - * @bus_id: PHY device to attach
 + * @phydev: Pointer to phy_device to attach
  * @flags: PHY device's dev_flags
  * @interface: PHY device's interface
  *
 @@ -358,22 +388,10 @@ EXPORT_SYMBOL(phy_disconnect);
  *     the attaching device, and given a callback for link status
  *     change.  The phy_device is returned to the attaching driver.
  */
 -struct phy_device *phy_attach(struct net_device *dev,
 -               const char *bus_id, u32 flags, phy_interface_t interface)
 +int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 +                     u32 flags, phy_interface_t interface)
  {
 -       struct bus_type *bus = mdio_bus_type;
 -       struct phy_device *phydev;
 -       struct device *d;
 -
 -       /* Search the list of PHY devices on the mdio bus for the
 -        * PHY with the requested name */
 -       d = bus_find_device_by_name(bus, NULL, bus_id);
 -       if (d) {
 -               phydev = to_phy_device(d);
 -       } else {
 -               printk(KERN_ERR %s not found\n, bus_id);
 -               return ERR_PTR(-ENODEV);
 -       }
 +       struct device *d = phydev-dev;

        /* Assume that if there is no driver, that it doesn't
         * exist, and we should use the genphy driver. */
 @@ -386,13 +404,12 @@ struct phy_device *phy_attach(struct net_device *dev,
                        err = device_bind_driver(d);

                if (err)
 -                       return ERR_PTR(err);
 +                       return err;
        }

        if (phydev-attached_dev) {
 -               printk(KERN_ERR %s: %s already attached\n,
 -                               dev-name, bus_id);
 -               

Re: [PATCH 4/9] openfirmware: Add OF phylib support code

2009-03-18 Thread Grant Likely
RFC, please don't apply yet.

On Wed, Mar 18, 2009 at 11:00 PM, Grant Likely
grant.lik...@secretlab.ca wrote:
 From: Grant Likely grant.lik...@secretlab.ca

 Add support for parsing the device tree for PHY devices on an MDIO bus

 CC: Andy Fleming aflem...@freescale.com
 CC: linuxppc-dev@ozlabs.org
 CC: devtree-disc...@ozlabs.org

 Signed-off-by: Grant Likely grant.lik...@secretlab.ca
 ---

  drivers/of/Kconfig      |    6 ++
  drivers/of/Makefile     |    1
  drivers/of/of_mdio.c    |  130 
 +++
  include/linux/of_mdio.h |   21 
  4 files changed, 158 insertions(+), 0 deletions(-)
  create mode 100644 drivers/of/of_mdio.c
  create mode 100644 include/linux/of_mdio.h


 diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
 index f821dbc..6fe043b 100644
 --- a/drivers/of/Kconfig
 +++ b/drivers/of/Kconfig
 @@ -19,3 +19,9 @@ config OF_SPI
        depends on OF  PPC_OF  SPI
        help
          OpenFirmware SPI accessors
 +
 +config OF_MDIO
 +       def_tristate PHYLIB
 +       depends on OF  PHYLIB
 +       help
 +         OpenFirmware MDIO bus (Ethernet PHY) accessors
 diff --git a/drivers/of/Makefile b/drivers/of/Makefile
 index 4c3c6f8..bdfb5f5 100644
 --- a/drivers/of/Makefile
 +++ b/drivers/of/Makefile
 @@ -3,3 +3,4 @@ obj-$(CONFIG_OF_DEVICE) += device.o platform.o
  obj-$(CONFIG_OF_GPIO)   += gpio.o
  obj-$(CONFIG_OF_I2C)   += of_i2c.o
  obj-$(CONFIG_OF_SPI)   += of_spi.o
 +obj-$(CONFIG_OF_MDIO)  += of_mdio.o
 diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
 new file mode 100644
 index 000..6f3038a
 --- /dev/null
 +++ b/drivers/of/of_mdio.c
 @@ -0,0 +1,130 @@
 +/*
 + * OF helpers for the MDIO (Ethernet PHY) API
 + *
 + * Copyright (c) 2009 Secret Lab Technologies, Ltd.
 + *
 + * This file is released under the GPLv2
 + *
 + * This file provides helper functions for extracting PHY device information
 + * out of the OpenFirmware device tree and using it to populate an mii_bus.
 + */
 +
 +#include linux/phy.h
 +#include linux/of.h
 +#include linux/of_mdio.h
 +#include linux/module.h
 +
 +MODULE_AUTHOR(Grant Likely grant.lik...@secretlab.ca);
 +MODULE_LICENSE(GPL);
 +
 +/**
 + * of_mdiobus_register - Register mii_bus and create PHYs from the device 
 tree
 + * @mdio: pointer to mii_bus structure
 + * @np: pointer to device_node of MDIO bus.
 + *
 + * This function registers the mii_bus structure and registers a phy_device
 + * for each child node of @np.
 + */
 +int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 +{
 +       struct phy_device *phy;
 +       struct device_node *child;
 +       int rc, i;
 +
 +       /* Mask out all PHYs from auto probing.  Instead the PHYs listed in
 +        * the device tree are populated after the bus has been registered */
 +       mdio-phy_mask = ~0;
 +
 +       /* Clear all the IRQ properties */
 +       if (mdio-irq)
 +               for (i=0; iPHY_MAX_ADDR; i++)
 +                       mdio-irq[i] = PHY_POLL;
 +
 +       /* Register the MDIO bus */
 +       rc = mdiobus_register(mdio);
 +       if (rc)
 +               return rc;
 +
 +       /* Loop over the child nodes and register a phy_device for each one */
 +       for_each_child_of_node(np, child) {
 +               const u32 *addr;
 +               int len;
 +
 +               /* A PHY must have a reg property in the range [0-31] */
 +               addr = of_get_property(child, reg, len);
 +               if (!addr || len  sizeof(*addr) || *addr = 32 || *addr  0) 
 {
 +                       dev_err(mdio-dev, %s has invalid PHY address\n,
 +                               child-full_name);
 +                       continue;
 +               }
 +
 +               if (mdio-irq) {
 +                       mdio-irq[*addr] = irq_of_parse_and_map(child, 0);
 +                       if (!mdio-irq[*addr])
 +                               mdio-irq[*addr] = PHY_POLL;
 +               }
 +
 +               phy = get_phy_device(mdio, *addr);
 +               if (!phy) {
 +                       dev_err(mdio-dev, error probing PHY at address 
 %i\n,
 +                               *addr);
 +                       continue;
 +               }
 +               phy_scan_fixups(phy);
 +
 +               /* Associate the OF node with the device structure so it
 +                * can be looked up later */
 +               of_node_get(child);
 +               dev_archdata_set_node(phy-dev.archdata, child);
 +
 +               /* All data is now stored in the phy struct; register it */
 +               rc = phy_device_register(phy);
 +               if (rc) {
 +                       phy_device_free(phy);
 +                       of_node_put(child);
 +                       continue;
 +               }
 +
 +               dev_dbg(mdio-dev, registered phy %s at address %i\n,
 +                       child-name, *addr);
 +       }
 +
 +       return 0;
 +}
 +EXPORT_SYMBOL(of_mdiobus_register);
 +
 +/**
 + * of_phy_connect - Connect to the phy 

Re: [PATCH 5/9] net: make mpc5200 fec driver use of_mdio infrastructure

2009-03-18 Thread Grant Likely
RFC, please don't apply yet.

On Wed, Mar 18, 2009 at 11:00 PM, Grant Likely
grant.lik...@secretlab.ca wrote:
 From: Grant Likely grant.lik...@secretlab.ca

 The patch reworks the MPC5200 Fast Ethernet Controller (FEC) driver to
 use the of_mdio infrastructure for registering PHY devices from data out
 openfirmware device tree, and eliminates the assumption that the PHY
 for the FEC is always attached to the FEC's own MDIO bus.  With this
 patch, the FEC can use a PHY attached to any MDIO bus if it is described
 in the device tree.
 ---

  drivers/net/Kconfig           |    2
  drivers/net/fec_mpc52xx.c     |  175 
 +++--
  drivers/net/fec_mpc52xx_phy.c |   26 +-
  3 files changed, 53 insertions(+), 150 deletions(-)


 diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
 index a2f185f..3aa24f6 100644
 --- a/drivers/net/Kconfig
 +++ b/drivers/net/Kconfig
 @@ -1854,7 +1854,7 @@ config FEC_MPC52xx

  config FEC_MPC52xx_MDIO
        bool MPC52xx FEC MDIO bus driver
 -       depends on FEC_MPC52xx
 +       depends on FEC_MPC52xx  OF_MDIO
        default y
        ---help---
          The MPC5200's FEC can connect to the Ethernet either with
 diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
 index 3d55f9a..12ab8ae 100644
 --- a/drivers/net/fec_mpc52xx.c
 +++ b/drivers/net/fec_mpc52xx.c
 @@ -25,6 +25,7 @@
  #include linux/hardirq.h
  #include linux/delay.h
  #include linux/of_device.h
 +#include linux/of_mdio.h
  #include linux/of_platform.h

  #include linux/netdevice.h
 @@ -43,11 +44,9 @@

  #define DRIVER_NAME mpc52xx-fec

 -#define FEC5200_PHYADDR_NONE   (-1)
 -#define FEC5200_PHYADDR_7WIRE  (-2)
 -
  /* Private driver data structure */
  struct mpc52xx_fec_priv {
 +       struct net_device *ndev;
        int duplex;
        int speed;
        int r_irq;
 @@ -59,10 +58,11 @@ struct mpc52xx_fec_priv {
        int msg_enable;

        /* MDIO link details */
 -       int phy_addr;
 -       unsigned int phy_speed;
 +       unsigned int mdio_speed;
 +       struct device_node *phy_node;
        struct phy_device *phydev;
        enum phy_state link;
 +       int seven_wire_mode;
  };


 @@ -210,66 +210,6 @@ static void mpc52xx_fec_adjust_link(struct net_device 
 *dev)
                phy_print_status(phydev);
  }

 -static int mpc52xx_fec_init_phy(struct net_device *dev)
 -{
 -       struct mpc52xx_fec_priv *priv = netdev_priv(dev);
 -       struct phy_device *phydev;
 -       char phy_id[BUS_ID_SIZE];
 -
 -       snprintf(phy_id, sizeof(phy_id), %x:%02x,
 -                       (unsigned int)dev-base_addr, priv-phy_addr);
 -
 -       priv-link = PHY_DOWN;
 -       priv-speed = 0;
 -       priv-duplex = -1;
 -
 -       phydev = phy_connect(dev, phy_id, mpc52xx_fec_adjust_link, 0, 
 PHY_INTERFACE_MODE_MII);
 -       if (IS_ERR(phydev)) {
 -               dev_err(dev-dev, phy_connect failed\n);
 -               return PTR_ERR(phydev);
 -       }
 -       dev_info(dev-dev, attached phy %i to driver %s\n,
 -                       phydev-addr, phydev-drv-name);
 -
 -       priv-phydev = phydev;
 -
 -       return 0;
 -}
 -
 -static int mpc52xx_fec_phy_start(struct net_device *dev)
 -{
 -       struct mpc52xx_fec_priv *priv = netdev_priv(dev);
 -       int err;
 -
 -       if (priv-phy_addr  0)
 -               return 0;
 -
 -       err = mpc52xx_fec_init_phy(dev);
 -       if (err) {
 -               dev_err(dev-dev, mpc52xx_fec_init_phy failed\n);
 -               return err;
 -       }
 -
 -       /* reset phy - this also wakes it from PDOWN */
 -       phy_write(priv-phydev, MII_BMCR, BMCR_RESET);
 -       phy_start(priv-phydev);
 -
 -       return 0;
 -}
 -
 -static void mpc52xx_fec_phy_stop(struct net_device *dev)
 -{
 -       struct mpc52xx_fec_priv *priv = netdev_priv(dev);
 -
 -       if (!priv-phydev)
 -               return;
 -
 -       phy_disconnect(priv-phydev);
 -       /* power down phy */
 -       phy_stop(priv-phydev);
 -       phy_write(priv-phydev, MII_BMCR, BMCR_PDOWN);
 -}
 -
  static int mpc52xx_fec_phy_mii_ioctl(struct mpc52xx_fec_priv *priv,
                struct mii_ioctl_data *mii_data, int cmd)
  {
 @@ -279,25 +219,25 @@ static int mpc52xx_fec_phy_mii_ioctl(struct 
 mpc52xx_fec_priv *priv,
        return phy_mii_ioctl(priv-phydev, mii_data, cmd);
  }

 -static void mpc52xx_fec_phy_hw_init(struct mpc52xx_fec_priv *priv)
 -{
 -       struct mpc52xx_fec __iomem *fec = priv-fec;
 -
 -       if (priv-phydev)
 -               return;
 -
 -       out_be32(fec-mii_speed, priv-phy_speed);
 -}
 -
  static int mpc52xx_fec_open(struct net_device *dev)
  {
        struct mpc52xx_fec_priv *priv = netdev_priv(dev);
        int err = -EBUSY;

 +       if (priv-phy_node) {
 +               priv-phydev = of_phy_connect(priv-ndev, priv-phy_node,
 +                                             mpc52xx_fec_adjust_link, 0, 0);
 +               if (!priv-phydev) {
 +                       dev_err(dev-dev, of_phy_connect failed\n);
 +                    

Re: [PATCH 6/9] net/gianfar: Rework gianfar driver to use OF PHY/MDIO helper functions

2009-03-18 Thread Grant Likely
RFC, please don't apply yet.

On Wed, Mar 18, 2009 at 11:00 PM, Grant Likely
grant.lik...@secretlab.ca wrote:
 From: Grant Likely grant.lik...@secretlab.ca

 This patch simplifies the driver by making use of more common code.

 Signed-off-by: Grant Likely grant.lik...@secretlab.ca
 ---

  drivers/net/gianfar.c     |   94 
 ++---
  drivers/net/gianfar.h     |    3 +
  drivers/net/gianfar_mii.c |   52 +
  3 files changed, 34 insertions(+), 115 deletions(-)


 diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
 index 9831b3f..0521267 100644
 --- a/drivers/net/gianfar.c
 +++ b/drivers/net/gianfar.c
 @@ -75,6 +75,7 @@
  #include linux/if_vlan.h
  #include linux/spinlock.h
  #include linux/mm.h
 +#include linux/of_mdio.h
  #include linux/of_platform.h
  #include linux/ip.h
  #include linux/tcp.h
 @@ -155,17 +156,13 @@ static inline int gfar_uses_fcb(struct gfar_private 
 *priv)

  static int gfar_of_init(struct net_device *dev)
  {
 -       struct device_node *phy, *mdio;
 -       const unsigned int *id;
        const char *model;
        const char *ctype;
        const void *mac_addr;
 -       const phandle *ph;
        u64 addr, size;
        int err = 0;
        struct gfar_private *priv = netdev_priv(dev);
        struct device_node *np = priv-node;
 -       char bus_name[MII_BUS_ID_SIZE];

        if (!np || !of_device_is_available(np))
                return -ENODEV;
 @@ -228,8 +225,8 @@ static int gfar_of_init(struct net_device *dev)
        if (of_get_property(np, fsl,magic-packet, NULL))
                priv-device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;

 -       ph = of_get_property(np, phy-handle, NULL);
 -       if (ph == NULL) {
 +       priv-phy_node = of_parse_phandle(np, phy-device, 0);
 +       if (!priv-phy_node) {
                u32 *fixed_link;

                fixed_link = (u32 *)of_get_property(np, fixed-link, NULL);
 @@ -237,57 +234,10 @@ static int gfar_of_init(struct net_device *dev)
                        err = -ENODEV;
                        goto err_out;
                }
 -
 -               snprintf(priv-phy_bus_id, sizeof(priv-phy_bus_id),
 -                               PHY_ID_FMT, 0, fixed_link[0]);
 -       } else {
 -               phy = of_find_node_by_phandle(*ph);
 -
 -               if (phy == NULL) {
 -                       err = -ENODEV;
 -                       goto err_out;
 -               }
 -
 -               mdio = of_get_parent(phy);
 -
 -               id = of_get_property(phy, reg, NULL);
 -
 -               of_node_put(phy);
 -               of_node_put(mdio);
 -
 -               gfar_mdio_bus_name(bus_name, mdio);
 -               snprintf(priv-phy_bus_id, sizeof(priv-phy_bus_id), 
 %s:%02x,
 -                               bus_name, *id);
        }

        /* Find the TBI PHY.  If it's not there, we don't support SGMII */
 -       ph = of_get_property(np, tbi-handle, NULL);
 -       if (ph) {
 -               struct device_node *tbi = of_find_node_by_phandle(*ph);
 -               struct of_device *ofdev;
 -               struct mii_bus *bus;
 -
 -               if (!tbi)
 -                       return 0;
 -
 -               mdio = of_get_parent(tbi);
 -               if (!mdio)
 -                       return 0;
 -
 -               ofdev = of_find_device_by_node(mdio);
 -
 -               of_node_put(mdio);
 -
 -               id = of_get_property(tbi, reg, NULL);
 -               if (!id)
 -                       return 0;
 -
 -               of_node_put(tbi);
 -
 -               bus = dev_get_drvdata(ofdev-dev);
 -
 -               priv-tbiphy = bus-phy_map[*id];
 -       }
 +       priv-tbi_node = of_parse_phandle(np, tbi-handle, 0);

        return 0;

 @@ -661,7 +611,6 @@ static int init_phy(struct net_device *dev)
        uint gigabit_support =
                priv-device_flags  FSL_GIANFAR_DEV_HAS_GIGABIT ?
                SUPPORTED_1000baseT_Full : 0;
 -       struct phy_device *phydev;
        phy_interface_t interface;

        priv-oldlink = 0;
 @@ -670,23 +619,38 @@ static int init_phy(struct net_device *dev)

        interface = gfar_get_interface(dev);

 -       phydev = phy_connect(dev, priv-phy_bus_id, adjust_link, 0, 
 interface);
 +       if (priv-phy_node) {
 +               priv-phydev = of_phy_connect(dev, priv-phy_node, 
 adjust_link,
 +                                             0, interface);
 +               if (!priv-phydev) {
 +                       dev_err(dev-dev, error: Could not attach to 
 PHY\n);
 +                       return -ENODEV;
 +               }
 +       }
 +
 +       if (priv-tbi_node) {
 +               priv-tbiphy = of_phy_connect(dev, priv-tbi_node, 
 adjust_link,
 +                                             0, interface);
 +               if (!priv-tbiphy) {
 +                       dev_err(dev-dev, error: Could not attach to 
 TBI\n);
 +                       goto err_tbiphy;
 +               }
 +       }

        if 

Re: [PATCH 7/9] net/ucc_geth: Rework ucc_geth driver to use OF PHY/MDIO helper functions

2009-03-18 Thread Grant Likely
RFC, please don't apply yet.

On Wed, Mar 18, 2009 at 11:00 PM, Grant Likely
grant.lik...@secretlab.ca wrote:
 From: Grant Likely grant.lik...@secretlab.ca

 This patch simplifies the driver by making use of more common code.

 Signed-off-by: Grant Likely grant.lik...@secretlab.ca
 ---

  drivers/net/ucc_geth.c     |   27 ++-
  drivers/net/ucc_geth_mii.c |   17 +++--
  2 files changed, 9 insertions(+), 35 deletions(-)


 diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
 index e879868..45bb627 100644
 --- a/drivers/net/ucc_geth.c
 +++ b/drivers/net/ucc_geth.c
 @@ -28,6 +28,7 @@
  #include linux/mii.h
  #include linux/phy.h
  #include linux/workqueue.h
 +#include linux/of_mdio.h
  #include linux/of_platform.h

  #include asm/uaccess.h
 @@ -1537,35 +1538,19 @@ static int init_phy(struct net_device *dev)
  {
        struct ucc_geth_private *priv = netdev_priv(dev);
        struct device_node *np = priv-node;
 -       struct device_node *phy, *mdio;
 -       const phandle *ph;
 -       char bus_name[MII_BUS_ID_SIZE];
 -       const unsigned int *id;
 +       struct device_node *phy;
        struct phy_device *phydev;
 -       char phy_id[BUS_ID_SIZE];

        priv-oldlink = 0;
        priv-oldspeed = 0;
        priv-oldduplex = -1;

 -       ph = of_get_property(np, phy-handle, NULL);
 -       phy = of_find_node_by_phandle(*ph);
 -       mdio = of_get_parent(phy);
 -
 -       id = of_get_property(phy, reg, NULL);
 -
 +       phy = of_parse_phandle(np, phy-handle, 0);
 +       phydev = of_phy_connect(dev, phy, adjust_link, 0, 
 priv-phy_interface);
        of_node_put(phy);
 -       of_node_put(mdio);
 -
 -       uec_mdio_bus_name(bus_name, mdio);
 -       snprintf(phy_id, sizeof(phy_id), %s:%02x,
 -                                bus_name, *id);
 -
 -       phydev = phy_connect(dev, phy_id, adjust_link, 0, 
 priv-phy_interface);
 -
 -       if (IS_ERR(phydev)) {
 +       if (!phydev) {
                printk(%s: Could not attach to PHY\n, dev-name);
 -               return PTR_ERR(phydev);
 +               return -ENODEV;
        }

        phydev-supported = (ADVERTISED_10baseT_Half |
 diff --git a/drivers/net/ucc_geth_mii.c b/drivers/net/ucc_geth_mii.c
 index 0ada4ed..9f2492f 100644
 --- a/drivers/net/ucc_geth_mii.c
 +++ b/drivers/net/ucc_geth_mii.c
 @@ -36,6 +36,7 @@
  #include linux/mii.h
  #include linux/phy.h
  #include linux/fsl_devices.h
 +#include linux/of_mdio.h
  #include linux/of_platform.h

  #include asm/io.h
 @@ -135,11 +136,10 @@ static int uec_mdio_probe(struct of_device *ofdev, 
 const struct of_device_id *ma
  {
        struct device *device = ofdev-dev;
        struct device_node *np = ofdev-node, *tempnp = NULL;
 -       struct device_node *child = NULL;
        struct ucc_mii_mng __iomem *regs;
        struct mii_bus *new_bus;
        struct resource res;
 -       int k, err = 0;
 +       int err = 0;

        new_bus = mdiobus_alloc();
        if (NULL == new_bus)
 @@ -165,17 +165,6 @@ static int uec_mdio_probe(struct of_device *ofdev, const 
 struct of_device_id *ma
                goto reg_map_fail;
        }

 -       for (k = 0; k  32; k++)
 -               new_bus-irq[k] = PHY_POLL;
 -
 -       while ((child = of_get_next_child(np, child)) != NULL) {
 -               int irq = irq_of_parse_and_map(child, 0);
 -               if (irq != NO_IRQ) {
 -                       const u32 *id = of_get_property(child, reg, NULL);
 -                       new_bus-irq[*id] = irq;
 -               }
 -       }
 -
        /* Set the base address */
        regs = ioremap(res.start, sizeof(struct ucc_mii_mng));

 @@ -220,7 +209,7 @@ static int uec_mdio_probe(struct of_device *ofdev, const 
 struct of_device_id *ma
                }
        }

 -       err = mdiobus_register(new_bus);
 +       err = of_mdiobus_register(new_bus, np);
        if (0 != err) {
                printk(KERN_ERR %s: Cannot register as MDIO bus\n,
                       new_bus-name);





-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 8/9] net/pasemi_mac: Rework pasemi_mac driver to use of_mdio infrastructure

2009-03-18 Thread Grant Likely
RFC, please don't apply yet.

On Wed, Mar 18, 2009 at 11:00 PM, Grant Likely
grant.lik...@secretlab.ca wrote:
 From: Grant Likely grant.lik...@secretlab.ca

 This patch simplifies the driver by making use of more common code.

 Signed-off-by: Grant Likely grant.lik...@secretlab.ca
 ---

  drivers/net/pasemi_mac.c |   19 +++
  drivers/net/pasemi_mac.h |    1 -
  2 files changed, 3 insertions(+), 17 deletions(-)


 diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
 index d0349e7..8c92d1f 100644
 --- a/drivers/net/pasemi_mac.c
 +++ b/drivers/net/pasemi_mac.c
 @@ -1086,34 +1086,21 @@ static int pasemi_mac_phy_init(struct net_device *dev)
        struct pasemi_mac *mac = netdev_priv(dev);
        struct device_node *dn, *phy_dn;
        struct phy_device *phydev;
 -       unsigned int phy_id;
        const phandle *ph;
        const unsigned int *prop;
        struct resource r;
        int ret;

        dn = pci_device_to_OF_node(mac-pdev);
 -       ph = of_get_property(dn, phy-handle, NULL);
 -       if (!ph)
 -               return -ENODEV;
 -       phy_dn = of_find_node_by_phandle(*ph);
 -
 -       prop = of_get_property(phy_dn, reg, NULL);
 -       ret = of_address_to_resource(phy_dn-parent, 0, r);
 -       if (ret)
 -               goto err;
 -
 -       phy_id = *prop;
 -       snprintf(mac-phy_id, sizeof(mac-phy_id), %x:%02x,
 -                (int)r.start, phy_id);
 -
 +       phy_dn = of_parse_phandle(dn, phy-handle, 0);
        of_node_put(phy_dn);

        mac-link = 0;
        mac-speed = 0;
        mac-duplex = -1;

 -       phydev = phy_connect(dev, mac-phy_id, pasemi_adjust_link, 0, 
 PHY_INTERFACE_MODE_SGMII);
 +       phydev = of_phy_connect(dev, phy_dn, pasemi_adjust_link, 0,
 +                               PHY_INTERFACE_MODE_SGMII);

        if (IS_ERR(phydev)) {
                printk(KERN_ERR %s: Could not attach to phy\n, dev-name);
 diff --git a/drivers/net/pasemi_mac.h b/drivers/net/pasemi_mac.h
 index 1a115ec..e2f4efa 100644
 --- a/drivers/net/pasemi_mac.h
 +++ b/drivers/net/pasemi_mac.h
 @@ -100,7 +100,6 @@ struct pasemi_mac {
        int     duplex;

        unsigned int    msg_enable;
 -       char    phy_id[BUS_ID_SIZE];
  };

  /* Software status descriptor (ring_info) */





-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 9/9] net/fs_enet: Rework fs_enet driver to use of_mdio infrastructure

2009-03-18 Thread Grant Likely
RFC, please don't apply yet.

On Wed, Mar 18, 2009 at 11:01 PM, Grant Likely
grant.lik...@secretlab.ca wrote:
 From: Grant Likely grant.lik...@secretlab.ca

 This patch simplifies the driver by making use of more common code.

 Signed-off-by: Grant Likely grant.lik...@secretlab.ca
 ---

  drivers/net/fs_enet/fs_enet-main.c |   66 
 +---
  drivers/net/fs_enet/mii-bitbang.c  |   29 +---
  drivers/net/fs_enet/mii-fec.c      |   26 +-
  include/linux/fs_enet_pd.h         |    6 +--
  4 files changed, 14 insertions(+), 113 deletions(-)


 diff --git a/drivers/net/fs_enet/fs_enet-main.c 
 b/drivers/net/fs_enet/fs_enet-main.c
 index ce900e5..e039d6a 100644
 --- a/drivers/net/fs_enet/fs_enet-main.c
 +++ b/drivers/net/fs_enet/fs_enet-main.c
 @@ -36,6 +36,8 @@
  #include linux/fs.h
  #include linux/platform_device.h
  #include linux/phy.h
 +#include linux/of.h
 +#include linux/of_mdio.h
  #include linux/of_platform.h
  #include linux/of_gpio.h

 @@ -752,9 +754,10 @@ static int fs_init_phy(struct net_device *dev)
        fep-oldlink = 0;
        fep-oldspeed = 0;
        fep-oldduplex = -1;
 -       if(fep-fpi-bus_id)
 -               phydev = phy_connect(dev, fep-fpi-bus_id, fs_adjust_link, 
 0,
 -                               PHY_INTERFACE_MODE_MII);
 +       if(fep-fpi-phy_node)
 +               phydev = of_phy_connect(dev, fep-fpi-phy_node,
 +                                       fs_adjust_link, 0,
 +                                       PHY_INTERFACE_MODE_MII);
        else {
                printk(No phy bus ID specified in BSP code\n);
                return -EINVAL;
 @@ -962,57 +965,6 @@ static void cleanup_immap(void)

  /**/

 -static int __devinit find_phy(struct device_node *np,
 -                              struct fs_platform_info *fpi)
 -{
 -       struct device_node *phynode, *mdionode;
 -       int ret = 0, len, bus_id;
 -       const u32 *data;
 -
 -       data  = of_get_property(np, fixed-link, NULL);
 -       if (data) {
 -               snprintf(fpi-bus_id, 16, %x:%02x, 0, *data);
 -               return 0;
 -       }
 -
 -       data = of_get_property(np, phy-handle, len);
 -       if (!data || len != 4)
 -               return -EINVAL;
 -
 -       phynode = of_find_node_by_phandle(*data);
 -       if (!phynode)
 -               return -EINVAL;
 -
 -       data = of_get_property(phynode, reg, len);
 -       if (!data || len != 4) {
 -               ret = -EINVAL;
 -               goto out_put_phy;
 -       }
 -
 -       mdionode = of_get_parent(phynode);
 -       if (!mdionode) {
 -               ret = -EINVAL;
 -               goto out_put_phy;
 -       }
 -
 -       bus_id = of_get_gpio(mdionode, 0);
 -       if (bus_id  0) {
 -               struct resource res;
 -               ret = of_address_to_resource(mdionode, 0, res);
 -               if (ret)
 -                       goto out_put_mdio;
 -               bus_id = res.start;
 -       }
 -
 -       snprintf(fpi-bus_id, 16, %x:%02x, bus_id, *data);
 -
 -out_put_mdio:
 -       of_node_put(mdionode);
 -out_put_phy:
 -       of_node_put(phynode);
 -       return ret;
 -}
 -
  #ifdef CONFIG_FS_ENET_HAS_FEC
  #define IS_FEC(match) ((match)-data == fs_fec_ops)
  #else
 @@ -1046,9 +998,9 @@ static int __devinit fs_enet_probe(struct of_device 
 *ofdev,
        fpi-rx_copybreak = 240;
        fpi-use_napi = 1;
        fpi-napi_weight = 17;
 -
 -       ret = find_phy(ofdev-node, fpi);
 -       if (ret)
 +       fpi-phy_node = of_parse_phandle(ofdev-node, phy-handle, 0);
 +       if ((!fpi-phy_node)  (!of_get_property(ofdev-node, fixed-link,
 +                                                 NULL)))
                goto out_free_fpi;

        privsize = sizeof(*fep) +
 diff --git a/drivers/net/fs_enet/mii-bitbang.c 
 b/drivers/net/fs_enet/mii-bitbang.c
 index 49b6645..93b481b 100644
 --- a/drivers/net/fs_enet/mii-bitbang.c
 +++ b/drivers/net/fs_enet/mii-bitbang.c
 @@ -22,6 +22,7 @@
  #include linux/mii.h
  #include linux/platform_device.h
  #include linux/mdio-bitbang.h
 +#include linux/of_mdio.h
  #include linux/of_platform.h

  #include fs_enet.h
 @@ -149,31 +150,12 @@ static int __devinit fs_mii_bitbang_init(struct mii_bus 
 *bus,
        return 0;
  }

 -static void __devinit add_phy(struct mii_bus *bus, struct device_node *np)
 -{
 -       const u32 *data;
 -       int len, id, irq;
 -
 -       data = of_get_property(np, reg, len);
 -       if (!data || len != 4)
 -               return;
 -
 -       id = *data;
 -       bus-phy_mask = ~(1  id);
 -
 -       irq = of_irq_to_resource(np, 0, NULL);
 -       if (irq != NO_IRQ)
 -               bus-irq[id] = irq;
 -}
 -
  static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
                                         const struct of_device_id *match)
  {
 -       struct device_node *np = NULL;
        struct mii_bus *new_bus;
        struct bb_info 

Re: [PATCH 1/9] of: add of_parse_phandle() helper for parsing phandle properties

2009-03-18 Thread Michael Ellerman
On Wed, 2009-03-18 at 23:00 -0600, Grant Likely wrote:
 From: Grant Likely grant.lik...@secretlab.ca
 
 of_parse_phandle() is a helper function to read and parse a phandle
 property and return a pointer to the resulting device_node.
 
 Signed-off-by: Grant Likely grant.lik...@secretlab.ca
 ---
 
  drivers/of/base.c  |   23 +++
  include/linux/of.h |3 +++
  2 files changed, 26 insertions(+), 0 deletions(-)
 
 
 diff --git a/drivers/of/base.c b/drivers/of/base.c
 index cd17092..1eaada4 100644
 --- a/drivers/of/base.c
 +++ b/drivers/of/base.c
 @@ -494,6 +494,29 @@ int of_modalias_node(struct device_node *node, char 
 *modalias, int len)
  EXPORT_SYMBOL_GPL(of_modalias_node);
  
  /**
 + * of_parse_phandle - Resolve a phandle property to a device_node pointer
 + * @np: Pointer to device node holding phandle property
 + * @phandle_name: Name of property holding a phandle value
 + * @index: For properties holding a table of phandles, this is the index into
 + * the table
 + *
 + * Returns the device_node pointer pointed to by the phandle, or NULL
 + */

I think it would good to follow the convention of many of the other of_
routines and have an explicit comment about the refcounting, eg:

 *  Returns a node pointer with refcount incremented, use
 *  of_node_put() on it when done.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person


signature.asc
Description: This is a digitally signed message part
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [PATCH 1/9] of: add of_parse_phandle() helper for parsing

2009-03-18 Thread sunder ramani
Hi Grant,

I have here one query though. I found out that there are various
configurations of the PHY device that my be connected to the eTSEC on
the 8548. I am talking only about this because I faced some issues.

My HW had RGMII, SGMII configurations for the different ports to the
PHYs. And the kernel doesnt know about how the interface from the
eTSEC to the physical PHY is. I do acknowledge the ignorance of the
MII layer, but I had to fix up some dirty patches in the phy code to
let me kernel do auto-neg, phy_init for a RGMII, SGMII, interface
differentaiting on the basis of the Phy-IDs. As a result, the PHY
layer would generalize the auto-neg and init functions for the copper
interface.

To Summarize, should not we have a phy_type flag in the OF tree which
will let the PHY layer do the various PHY tasks based on if it is a
copper/fiber interface. I really dont like my fix in my kernel and am
new to open source. Do you think it is a valid argument? If it so, I
would like to plan to introduce those changes and post to the
community.

Please let me know your comments!

Thanx!
Sundar

On Thu, Mar 19, 2009 at 10:35 AM,  linuxppc-dev-requ...@ozlabs.org wrote:
 Send Linuxppc-dev mailing list submissions to
        linuxppc-...@ozlabs.org

 To subscribe or unsubscribe via the World Wide Web, visit
        https://ozlabs.org/mailman/listinfo/linuxppc-dev
 or, via email, send a message with subject or body 'help' to
        linuxppc-dev-requ...@ozlabs.org

 You can reach the person managing the list at
        linuxppc-dev-ow...@ozlabs.org

 When replying, please edit your Subject line so it is more specific
 than Re: Contents of Linuxppc-dev digest...


 Today's Topics:

   1. [PATCH 6/9] net/gianfar: Rework gianfar driver to use OF
      PHY/MDIO  helper functions (Grant Likely)
   2. [PATCH 7/9] net/ucc_geth: Rework ucc_geth driver to use OF
      PHY/MDIO  helper functions (Grant Likely)
   3. [PATCH 8/9] net/pasemi_mac: Rework pasemi_mac driver to use
      of_mdio   infrastructure (Grant Likely)
   4. [PATCH 9/9] net/fs_enet: Rework fs_enet driver to use of_mdio
      infrastructure (Grant Likely)
   5. Re: [PATCH 1/9] of: add of_parse_phandle() helper for parsing
      phandle   properties (Grant Likely)


 --

 Message: 1
 Date: Wed, 18 Mar 2009 23:00:44 -0600
 From: Grant Likely grant.lik...@secretlab.ca
 Subject: [PATCH 6/9] net/gianfar: Rework gianfar driver to use OF
        PHY/MDIO        helper functions
 To: linuxppc-dev@ozlabs.org, net...@vger.kernel.org,
        aflem...@freescale.com, avoront...@ru.mvista.com, da...@davemloft.net,
        ga...@kernel.crashing.org
 Message-ID: 20090319050043.11320.96160.st...@localhost.localdomain
 Content-Type: text/plain; charset=utf-8

 From: Grant Likely grant.lik...@secretlab.ca

 This patch simplifies the driver by making use of more common code.

 Signed-off-by: Grant Likely grant.lik...@secretlab.ca
 ---

  drivers/net/gianfar.c     |   94 
 ++---
  drivers/net/gianfar.h     |    3 +
  drivers/net/gianfar_mii.c |   52 +
  3 files changed, 34 insertions(+), 115 deletions(-)


 diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
 index 9831b3f..0521267 100644
 --- a/drivers/net/gianfar.c
 +++ b/drivers/net/gianfar.c
 @@ -75,6 +75,7 @@
  #include linux/if_vlan.h
  #include linux/spinlock.h
  #include linux/mm.h
 +#include linux/of_mdio.h
  #include linux/of_platform.h
  #include linux/ip.h
  #include linux/tcp.h
 @@ -155,17 +156,13 @@ static inline int gfar_uses_fcb(struct gfar_private 
 *priv)

  static int gfar_of_init(struct net_device *dev)
  {
 -       struct device_node *phy, *mdio;
 -       const unsigned int *id;
        const char *model;
        const char *ctype;
        const void *mac_addr;
 -       const phandle *ph;
        u64 addr, size;
        int err = 0;
        struct gfar_private *priv = netdev_priv(dev);
        struct device_node *np = priv-node;
 -       char bus_name[MII_BUS_ID_SIZE];

        if (!np || !of_device_is_available(np))
                return -ENODEV;
 @@ -228,8 +225,8 @@ static int gfar_of_init(struct net_device *dev)
        if (of_get_property(np, fsl,magic-packet, NULL))
                priv-device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;

 -       ph = of_get_property(np, phy-handle, NULL);
 -       if (ph == NULL) {
 +       priv-phy_node = of_parse_phandle(np, phy-device, 0);
 +       if (!priv-phy_node) {
                u32 *fixed_link;

                fixed_link = (u32 *)of_get_property(np, fixed-link, NULL);
 @@ -237,57 +234,10 @@ static int gfar_of_init(struct net_device *dev)
                        err = -ENODEV;
                        goto err_out;
                }
 -
 -               snprintf(priv-phy_bus_id, sizeof(priv-phy_bus_id),
 -                               PHY_ID_FMT, 0, fixed_link[0]);
 -       } else {
 -               phy = 

Re: [PATCH 9/9] net/fs_enet: Rework fs_enet driver to use of_mdio infrastructure

2009-03-18 Thread David Miller
From: Grant Likely grant.lik...@secretlab.ca
Date: Wed, 18 Mar 2009 23:07:35 -0600

 RFC, please don't apply yet.

You know, if you have posted a 0/9 patch explaining the purpose
and intent of the patch series, you'd only need to re-shit into
my inbox one time to say this stuff is RFC and don't apply yet
instead of 9 FREAKIN' TIMES!
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev