Re: [PATCH] using mii-bitbang on different processor ports - update the booting-without-of.txt-file

2007-11-09 Thread Sergej Stepanov
Am Donnerstag, den 08.11.2007, 14:20 -0600 schrieb Scott Wood: 
 Sergej Stepanov wrote:
  If both mdio and mdc controlling pins are on the same processor port,
  one resource should be used.
  Otherwise, two resources are used: the 1-st - mdio, the 2-nd - mdc.
 
 How about:
 The first reg resource is the I/O port register block on which MDIO 
 resides.  The second reg resource is the I/O port register block on 
 which MDC resides.  If there is only one reg resource, it is used for 
 both MDIO and MDC.
 
Ok.

 We also need to change the reference to port C in fsl,mdio-pin and 
 fsl,mdc-pin.
Do you mean this:
   Currently defined compatibles:
   fsl,pq1-fec-mdio (reg is same as first resource of FEC device)
- fsl,cpm2-mdio-bitbang (reg is port C registers)

   Properties for fsl,cpm2-mdio-bitbang:
- fsl,mdio-pin : pin of port C controlling mdio data
- fsl,mdc-pin : pin of port C controlling mdio clock

Right. But i thought it would be related to the example,
and than the reader gets the short comment about I/O ports.

Or the other variant would be:

   iv) MDIO

   Currently defined compatibles:
   fsl,pq1-fec-mdio (reg is same as first resource of FEC device)
   fsl,cpm2-mdio-bitbang (reg is the I/O port register block(s))

   Properties for fsl,cpm2-mdio-bitbang:
   The first reg resource is the I/O port register block on which MDIO
   resides.  The second reg resource is the I/O port register block on
   which MDC resides.  If there is only one reg resource, it is used for
   both MDIO and MDC.
   fsl,mdio-pin : pin of chosen port for controlling mdio data
   fsl,mdc-pin : pin of chosen port for controlling mdio clock

   Example:
[EMAIL PROTECTED] {
device_type = mdio;
compatible = fsl,mpc8272ads-mdio-bitbang,
 fsl,mpc8272-mdio-bitbang,
 fsl,cpm2-mdio-bitbang;
reg = 10d40 14;
#address-cells = 1;
#size-cells = 0;
fsl,mdio-pin = 12;
fsl,mdc-pin = 13;
};
-

Regards
Sergej.

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


Re: [PATCH] using mii-bitbang on different processor ports - update the booting-without-of.txt-file

2007-11-09 Thread Scott Wood
Sergej Stepanov wrote:
 We also need to change the reference to port C in fsl,mdio-pin and 
 fsl,mdc-pin.
 Do you mean this:
Currently defined compatibles:
fsl,pq1-fec-mdio (reg is same as first resource of FEC device)
 - fsl,cpm2-mdio-bitbang (reg is port C registers)
 
Properties for fsl,cpm2-mdio-bitbang:
 - fsl,mdio-pin : pin of port C controlling mdio data
 - fsl,mdc-pin : pin of port C controlling mdio clock

Yes.

 Right. But i thought it would be related to the example,
 and than the reader gets the short comment about I/O ports.

No, the example is the example, and the spec is the spec. :-)

 Or the other variant would be:
 
iv) MDIO
 
Currently defined compatibles:
fsl,pq1-fec-mdio (reg is same as first resource of FEC device)
fsl,cpm2-mdio-bitbang (reg is the I/O port register block(s))
 
Properties for fsl,cpm2-mdio-bitbang:
The first reg resource is the I/O port register block on which MDIO
resides.  The second reg resource is the I/O port register block on
which MDC resides.  If there is only one reg resource, it is used for
both MDIO and MDC.
fsl,mdio-pin : pin of chosen port for controlling mdio data
fsl,mdc-pin : pin of chosen port for controlling mdio clock

Looks good.  We can eliminate the parenthetical for 
fsl,cpm2-mdio-bitbang because reg is now explained below.

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


Re: [PATCH] using mii-bitbang on different processor ports - update the booting-without-of.txt-file

2007-11-08 Thread Scott Wood
Sergej Stepanov wrote:
 If both mdio and mdc controlling pins are on the same processor port,
 one resource should be used.
 Otherwise, two resources are used: the 1-st - mdio, the 2-nd - mdc.

How about:
The first reg resource is the I/O port register block on which MDIO 
resides.  The second reg resource is the I/O port register block on 
which MDC resides.  If there is only one reg resource, it is used for 
both MDIO and MDC.

We also need to change the reference to port C in fsl,mdio-pin and 
fsl,mdc-pin.

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


Re: [PATCH] using mii-bitbang on different processor ports - update the booting-without-of.txt-file

2007-11-07 Thread Sergej Stepanov
Am Dienstag, den 06.11.2007, 12:46 -0600 schrieb Scott Wood:
   
  +   The reg-property may have also depending on board design
  +   the following form:
  +   reg = 10d40 14 10d60 14;
  +   In that case the pin for mdio data controlling is on the port C,
  +   and the pin for mdio clock controlling is on the port D.
 
 It'd be better to explicitly say that the first resource is mdio, and the
 second resource is mdc, rather than require the reader to know/look up which
 corresponds to 10d40 and which to 10d60.
 
 -Scott

Ok. What would you say about something like that:
--
If both mdio and mdc controlling pins are on the same processor port,
one resource should be used.
Otherwise, two resources are used: the 1-st - mdio, the 2-nd - mdc.
--
Please, correct me, if it sounds bad.

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


[PATCH] using mii-bitbang on different processor ports - update the booting-without-of.txt-file

2007-11-06 Thread Sergej Stepanov
The patch updates the booting-without-of.txt-file.
There is a description for the case
if mdio data and clock pins are on different processor ports.
It is a extending for e-mail [PATCH v3] using mii-bitbang on different 
processor ports.

Signed-off-by: Sergej Stepanov [EMAIL PROTECTED]
--

diff --git a/Documentation/powerpc/booting-without-of.txt 
b/Documentation/powerpc/booting-without-of.txt
index a96e853..497d8d8 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -1956,6 +1956,12 @@ platforms are moved over to use the 
flattened-device-tree model.
fsl,mdc-pin = 13;
};
 
+   The reg-property may have also depending on board design
+   the following form:
+   reg = 10d40 14 10d60 14;
+   In that case the pin for mdio data controlling is on the port C,
+   and the pin for mdio clock controlling is on the port D.
+
v) Baud Rate Generators
 
Currently defined compatibles:

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


Re: [PATCH] using mii-bitbang on different processor ports - update the booting-without-of.txt-file

2007-11-06 Thread Scott Wood
On Tue, Nov 06, 2007 at 09:51:57AM +0100, Sergej Stepanov wrote:
 The patch updates the booting-without-of.txt-file.
 There is a description for the case
 if mdio data and clock pins are on different processor ports.
 It is a extending for e-mail [PATCH v3] using mii-bitbang on different 
 processor ports.
 
 Signed-off-by: Sergej Stepanov [EMAIL PROTECTED]
 --
 
 diff --git a/Documentation/powerpc/booting-without-of.txt 
 b/Documentation/powerpc/booting-without-of.txt
 index a96e853..497d8d8 100644
 --- a/Documentation/powerpc/booting-without-of.txt
 +++ b/Documentation/powerpc/booting-without-of.txt
 @@ -1956,6 +1956,12 @@ platforms are moved over to use the 
 flattened-device-tree model.
   fsl,mdc-pin = 13;
   };
  
 +   The reg-property may have also depending on board design
 +   the following form:
 + reg = 10d40 14 10d60 14;
 +   In that case the pin for mdio data controlling is on the port C,
 +   and the pin for mdio clock controlling is on the port D.

It'd be better to explicitly say that the first resource is mdio, and the
second resource is mdc, rather than require the reader to know/look up which
corresponds to 10d40 and which to 10d60.

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


Re: [PATCH] using mii-bitbang on different processor ports

2007-11-02 Thread Scott Wood
On Tue, Oct 30, 2007 at 05:09:19PM +0100, Sergej Stepanov wrote:
 The patch makes possible to have mdio and mdc pins on different physical ports
 also for CONFIG_PPC_CPM_NEW_BINDING.
 To setup it in the device tree:
 reg = 10d40 14 10d60 14; // mdc-offset: 0x10d40, mdio-offset: 0x10d60
 or
 reg = 10d40 14; // mdc and mdio have the same offset 0x10d40
 The approach was taken from older version.

There are some formatting issues in fs_mii_bitbang_init(), but otherwise it
looks good.  It'll need to be sent to Jeff Garzik and the netdev list, not
just linuxppc-dev, though.

Also, please update Documentation/powerpc/booting-without-of.txt (probably
in a separate patch, since that one would go through Paul).

 @@ -142,13 +146,27 @@ static int __devinit fs_mii_bitbang_init(struct mii_bus 
 *bus,
   return -ENODEV;
   mdc_pin = *data;
  
 - bitbang-dir = ioremap(res.start, res.end - res.start + 1);
 - if (!bitbang-dir)
 + bitbang-mdc.dir = ioremap(res[0].start, res[0].end - res[0].start + 1);
 + if (!bitbang-mdc.dir)
   return -ENOMEM;
  
 - bitbang-dat = bitbang-dir + 4;
 - bitbang-mdio_msk = 1  (31 - mdio_pin);
 - bitbang-mdc_msk = 1  (31 - mdc_pin);
 + bitbang-mdc.dat = bitbang-mdc.dir + 4;
 + if( !of_address_to_resource(np, 1, res[1]))

Space before the '(', not after.  A newline after the previous line would be
nice, too.

 + {

Brace at the end of the previous line.

 + bitbang-mdio.dir = ioremap(res[1].start, res[1].end - 
 res[1].start + 1);
 + if (!bitbang-mdio.dir)
 + {

Likewise.

You could just use of_iomap() for the second one, since we don't need
the physical address for bus-id.

 + iounmap(bitbang-mdc.dir);
 + return -ENOMEM;

Please use the goto-style error handling that's used elsewhere in the
function.

 + }
 + bitbang-mdio.dat = bitbang-mdio.dir + 4;
 + }
 + else{

} else {

  out_unmap_regs:
 - iounmap(bitbang-dir);
 + if ( bitbang-mdio.dir != bitbang-mdc.dir)
 + iounmap(bitbang-mdio.dir);
 + iounmap(bitbang-mdc.dir);
  out_free_bus:
   kfree(new_bus);
  out_free_priv:
 @@ -238,7 +258,9 @@ static int fs_enet_mdio_remove(struct of_device *ofdev)
   free_mdio_bitbang(bus);
   dev_set_drvdata(ofdev-dev, NULL);
   kfree(bus-irq);
 - iounmap(bitbang-dir);
 + if ( bitbang-mdio.dir != bitbang-mdc.dir)
 + iounmap(bitbang-mdio.dir);
 + iounmap(bitbang-mdc.dir);
   kfree(bitbang);
   kfree(bus);

if (bitbang, not if ( bitbang.

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


[PATCH] using mii-bitbang on different processor ports

2007-10-30 Thread Sergej Stepanov
The patch makes possible to have mdio and mdc pins on different physical ports
also for CONFIG_PPC_CPM_NEW_BINDING.
To setup it in the device tree:
reg = 10d40 14 10d60 14; // mdc-offset: 0x10d40, mdio-offset: 0x10d60
or
reg = 10d40 14; // mdc and mdio have the same offset 0x10d40
The approach was taken from older version.

Signed-off-by: Sergej Stepanov [EMAIL PROTECTED]
--
diff --git a/drivers/net/fs_enet/mii-bitbang.c 
b/drivers/net/fs_enet/mii-bitbang.c
index b8e4a73..86b73ea 100644
--- a/drivers/net/fs_enet/mii-bitbang.c
+++ b/drivers/net/fs_enet/mii-bitbang.c
@@ -29,12 +29,16 @@
 
 #include fs_enet.h
 
-struct bb_info {
-   struct mdiobb_ctrl ctrl;
+struct bb_port {
__be32 __iomem *dir;
__be32 __iomem *dat;
-   u32 mdio_msk;
-   u32 mdc_msk;
+   u32 msk;
+};
+
+struct bb_info {
+   struct mdiobb_ctrl ctrl;
+   struct bb_port mdc;
+   struct bb_port mdio;
 };
 
 /* FIXME: If any other users of GPIO crop up, then these will have to
@@ -62,18 +66,18 @@ static inline void mdio_dir(struct mdiobb_ctrl *ctrl, int 
dir)
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
 
if (dir)
-   bb_set(bitbang-dir, bitbang-mdio_msk);
+   bb_set(bitbang-mdio.dir, bitbang-mdio.msk);
else
-   bb_clr(bitbang-dir, bitbang-mdio_msk);
+   bb_clr(bitbang-mdio.dir, bitbang-mdio.msk);
 
/* Read back to flush the write. */
-   in_be32(bitbang-dir);
+   in_be32(bitbang-mdio.dir);
 }
 
 static inline int mdio_read(struct mdiobb_ctrl *ctrl)
 {
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
-   return bb_read(bitbang-dat, bitbang-mdio_msk);
+   return bb_read(bitbang-mdio.dat, bitbang-mdio.msk);
 }
 
 static inline void mdio(struct mdiobb_ctrl *ctrl, int what)
@@ -81,12 +85,12 @@ static inline void mdio(struct mdiobb_ctrl *ctrl, int what)
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
 
if (what)
-   bb_set(bitbang-dat, bitbang-mdio_msk);
+   bb_set(bitbang-mdio.dat, bitbang-mdio.msk);
else
-   bb_clr(bitbang-dat, bitbang-mdio_msk);
+   bb_clr(bitbang-mdio.dat, bitbang-mdio.msk);
 
/* Read back to flush the write. */
-   in_be32(bitbang-dat);
+   in_be32(bitbang-mdio.dat);
 }
 
 static inline void mdc(struct mdiobb_ctrl *ctrl, int what)
@@ -94,12 +98,12 @@ static inline void mdc(struct mdiobb_ctrl *ctrl, int what)
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
 
if (what)
-   bb_set(bitbang-dat, bitbang-mdc_msk);
+   bb_set(bitbang-mdc.dat, bitbang-mdc.msk);
else
-   bb_clr(bitbang-dat, bitbang-mdc_msk);
+   bb_clr(bitbang-mdc.dat, bitbang-mdc.msk);
 
/* Read back to flush the write. */
-   in_be32(bitbang-dat);
+   in_be32(bitbang-mdc.dat);
 }
 
 static struct mdiobb_ops bb_ops = {
@@ -114,23 +118,23 @@ static struct mdiobb_ops bb_ops = {
 static int __devinit fs_mii_bitbang_init(struct mii_bus *bus,
  struct device_node *np)
 {
-   struct resource res;
+   struct resource res[2];
const u32 *data;
int mdio_pin, mdc_pin, len;
struct bb_info *bitbang = bus-priv;
 
-   int ret = of_address_to_resource(np, 0, res);
+   int ret = of_address_to_resource(np, 0, res[0]);
if (ret)
return ret;
 
-   if (res.end - res.start  13)
+   if (res[0].end - res[0].start  13)
return -ENODEV;
 
/* This should really encode the pin number as well, but all
 * we get is an int, and the odds of multiple bitbang mdio buses
 * is low enough that it's not worth going too crazy.
 */
-   bus-id = res.start;
+   bus-id = res[0].start;
 
data = of_get_property(np, fsl,mdio-pin, len);
if (!data || len != 4)
@@ -142,13 +146,27 @@ static int __devinit fs_mii_bitbang_init(struct mii_bus 
*bus,
return -ENODEV;
mdc_pin = *data;
 
-   bitbang-dir = ioremap(res.start, res.end - res.start + 1);
-   if (!bitbang-dir)
+   bitbang-mdc.dir = ioremap(res[0].start, res[0].end - res[0].start + 1);
+   if (!bitbang-mdc.dir)
return -ENOMEM;
 
-   bitbang-dat = bitbang-dir + 4;
-   bitbang-mdio_msk = 1  (31 - mdio_pin);
-   bitbang-mdc_msk = 1  (31 - mdc_pin);
+   bitbang-mdc.dat = bitbang-mdc.dir + 4;
+   if( !of_address_to_resource(np, 1, res[1]))
+   {
+   bitbang-mdio.dir = ioremap(res[1].start, res[1].end - 
res[1].start + 1);
+   if (!bitbang-mdio.dir)
+   {
+   iounmap(bitbang-mdc.dir);
+   return -ENOMEM;
+   }
+   bitbang-mdio.dat = bitbang-mdio.dir + 4;
+   }
+   else{
+   bitbang-mdio.dir = 

Re: [PATCH] using mii-bitbang on different processor ports

2007-10-30 Thread Sergej Stepanov
Hello Scott.
Thank you for reply.
Am Dienstag, den 30.10.2007, 11:32 -0500 schrieb Scott Wood:
 On Tue, Oct 30, 2007 at 05:09:19PM +0100, Sergej Stepanov wrote:

 You could just use of_iomap() for the second one, since we don't need
 the physical address for bus-id.
Nice tip.
Than it would be needless---
|
\/
  +   iounmap(bitbang-mdc.dir);
  +   return -ENOMEM;
 
 Please use the goto-style error handling that's used elsewhere in the
 function.
Regards
Sergej.
 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] using mii-bitbang on different processor ports

2007-10-30 Thread Scott Wood
Sergej Stepanov wrote:
 Hello Scott.
 Thank you for reply.
 Am Dienstag, den 30.10.2007, 11:32 -0500 schrieb Scott Wood:
 On Tue, Oct 30, 2007 at 05:09:19PM +0100, Sergej Stepanov wrote:
 
 You could just use of_iomap() for the second one, since we don't need
 the physical address for bus-id.
 Nice tip.
 Than it would be needless---
   |
   \/
 +   iounmap(bitbang-mdc.dir);
 +   return -ENOMEM;
 Please use the goto-style error handling that's used elsewhere in the
 function.

Hmm... in this case, it'd be impossible to tell using of_iomap() whether 
a failure was due to reg only having one resource (and thus meaning the 
same one should be used for both), or due to ioremap() failure.  Maybe 
we should keep it separate.

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