Re: [PATCH 1/5] net: Add EMAC ethernet driver found on Allwinner A10 SoC's

2013-04-04 Thread Stefan Roese
Hi Florian,

On 24.03.2013 20:03, Florian Fainelli wrote:
> Your phylib implementation looks good now, just some minor comments below:

Thanks for the review. I'll try to address your new comments in a few
days (currently swamped).

Thanks,
Stefan

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v3] mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking

2013-01-18 Thread Stefan Roese
Currently cfi_cmdset_0002.c does not support PPB locking of sectors. This
patch adds support for this locking/unlocking mechanism. It is needed on
some platforms, since newer U-Boot versions do support this PPB locking
and protect for example their environment sector(s) this way.

This PPB locking/unlocking will be enabled for all devices supported by
cfi_cmdset_0002 reporting 8 in the CFI word 0x49 (Sector Protect/Unprotect
scheme).

Please note that PPB locking does support sector-by-sector locking. But
the whole chip can only be unlocked together. So unlocking one sector
will automatically unlock all sectors of this device. Because of this
chip limitation, the PPB unlocking function saves the current locking
status of all sectors before unlocking the whole device. After unlocking
the saved locking status is re-configured. This way only the addressed
sectors will be unlocked.

To selectively enable this advanced sector protection mechanism, the
device-tree property "use-advanced-sector-protection" has been created.
To enable support for this locking this property needs to be present in the
flash DT node. E.g.:

nor_flash@0,0 {
compatible = "amd,s29gl256n", "cfi-flash";
bank-width = <2>;
use-advanced-sector-protection;
...

Tested with Spanion S29GL512S10THI and Micron JS28F512M29EWx flash
devices.

Signed-off-by: Stefan Roese 
Tested-by: Holger Brunck 
Cc: Artem Bityutskiy 
---
v3:
- Added #ifdef CONFIG_OF to of_property_read_bool() probing code
- Rebased upon l2-mtd master branch

v2:
- Use msecs_to_jiffies
- Use UDELAY macro

 .../devicetree/bindings/mtd/mtd-physmap.txt|   3 +
 drivers/mtd/chips/cfi_cmdset_0002.c| 212 +
 drivers/mtd/maps/physmap_of.c  |   1 +
 include/linux/mtd/map.h|   1 +
 4 files changed, 217 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt 
b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
index dab7847..61c5ec8 100644
--- a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
+++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
@@ -26,6 +26,9 @@ file systems on embedded devices.
  - linux,mtd-name: allow to specify the mtd name for retro capability with
physmap-flash drivers as boot loader pass the mtd partition via the old
device name physmap-flash.
+ - use-advanced-sector-protection: boolean to enable support for the
+   advanced sector protection (Spansion: PPB - Persistent Protection
+   Bits) locking.
 
 For JEDEC compatible devices, the following additional properties
 are defined:
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c 
b/drivers/mtd/chips/cfi_cmdset_0002.c
index b861972..5d5ed93 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -74,6 +75,10 @@ static void put_chip(struct map_info *map, struct flchip 
*chip, unsigned long ad
 static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
 static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
 
+static int cfi_ppb_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
+static int cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
+static int cfi_ppb_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
+
 static struct mtd_chip_driver cfi_amdstd_chipdrv = {
.probe  = NULL, /* Not usable directly */
.destroy= cfi_amdstd_destroy,
@@ -496,6 +501,7 @@ static void cfi_fixup_m29ew_delay_after_resume(struct 
cfi_private *cfi)
 struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
 {
struct cfi_private *cfi = map->fldrv_priv;
+   struct device_node *np = map->device_node;
struct mtd_info *mtd;
int i;
 
@@ -570,6 +576,17 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int 
primary)
cfi_tell_features(extp);
 #endif
 
+#ifdef CONFIG_OF
+   if (np && of_property_read_bool(
+   np, "use-advanced-sector-protection")
+   && extp->BlkProtUnprot == 8) {
+   printk(KERN_INFO "  Advanced Sector Protection 
(PPB Locking) supported\n");
+   mtd->_lock = cfi_ppb_lock;
+   mtd->_unlock = cfi_ppb_unlock;
+   mtd->_is_locked = cfi_ppb_is_locked;
+   }
+#endif
+
bootloc = extp->TopBottom;
if ((bootloc < 2) || (bootloc > 5)) {
printk(KERN_WARNING "%s: CFI contains 
unrecognised boot "
@@ -2172,6 +2189,201 @@ static int cfi_atmel_unlock(struct mtd_info *mtd, 
loff_t ofs, uint

[PATCH v2] mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking

2012-12-13 Thread Stefan Roese
Currently cfi_cmdset_0002.c does not support PPB locking of sectors. This
patch adds support for this locking/unlocking mechanism. It is needed on
some platforms, since newer U-Boot versions do support this PPB locking
and protect for example their environment sector(s) this way.

This PPB locking/unlocking will be enabled for all devices supported by
cfi_cmdset_0002 reporting 8 in the CFI word 0x49 (Sector Protect/Unprotect
scheme).

Please note that PPB locking does support sector-by-sector locking. But
the whole chip can only be unlocked together. So unlocking one sector
will automatically unlock all sectors of this device. Because of this
chip limitation, the PPB unlocking function saves the current locking
status of all sectors before unlocking the whole device. After unlocking
the saved locking status is re-configured. This way only the addressed
sectors will be unlocked.

To selectively enable this advanced sector protection mechanism, the
device-tree property "use-advanced-sector-protection" has been created.
To enable support for this locking this property needs to be present in the
flash DT node. E.g.:

nor_flash@0,0 {
compatible = "amd,s29gl256n", "cfi-flash";
bank-width = <2>;
use-advanced-sector-protection;
...

Tested with Spanion S29GL512S10THI and Micron JS28F512M29EWx flash
devices.

Signed-off-by: Stefan Roese 
Tested-by: Holger Brunck 
Cc: Artem Bityutskiy 
---
v2:
- Use msecs_to_jiffies
- Use UDELAY macro

 .../devicetree/bindings/mtd/mtd-physmap.txt|   3 +
 drivers/mtd/chips/cfi_cmdset_0002.c| 210 +
 drivers/mtd/maps/physmap_of.c  |   1 +
 include/linux/mtd/map.h|   1 +
 4 files changed, 215 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt 
b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
index 94de19b..15902b8 100644
--- a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
+++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
@@ -23,6 +23,9 @@ file systems on embedded devices.
unaligned accesses as implemented in the JFFS2 code via memcpy().
By defining "no-unaligned-direct-access", the flash will not be
exposed directly to the MTD users (e.g. JFFS2) any more.
+ - use-advanced-sector-protection: boolean to enable support for the
+   advanced sector protection (Spansion: PPB - Persistent Protection
+   Bits) locking.
 
 For JEDEC compatible devices, the following additional properties
 are defined:
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c 
b/drivers/mtd/chips/cfi_cmdset_0002.c
index 5ff5c4a..306e7b9 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -74,6 +75,10 @@ static void put_chip(struct map_info *map, struct flchip 
*chip, unsigned long ad
 static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
 static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
 
+static int cfi_ppb_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
+static int cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
+static int cfi_ppb_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
+
 static struct mtd_chip_driver cfi_amdstd_chipdrv = {
.probe  = NULL, /* Not usable directly */
.destroy= cfi_amdstd_destroy,
@@ -496,6 +501,7 @@ static void cfi_fixup_m29ew_delay_after_resume(struct 
cfi_private *cfi)
 struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
 {
struct cfi_private *cfi = map->fldrv_priv;
+   struct device_node *np = map->device_node;
struct mtd_info *mtd;
int i;
 
@@ -570,6 +576,15 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int 
primary)
cfi_tell_features(extp);
 #endif
 
+   if (np && of_property_read_bool(
+   np, "use-advanced-sector-protection")
+   && extp->BlkProtUnprot == 8) {
+   printk(KERN_INFO "  Advanced Sector Protection 
(PPB Locking) supported\n");
+   mtd->_lock = cfi_ppb_lock;
+   mtd->_unlock = cfi_ppb_unlock;
+   mtd->_is_locked = cfi_ppb_is_locked;
+   }
+
bootloc = extp->TopBottom;
if ((bootloc < 2) || (bootloc > 5)) {
printk(KERN_WARNING "%s: CFI contains 
unrecognised boot "
@@ -2160,6 +2175,201 @@ static int cfi_atmel_unlock(struct mtd_info *mtd, 
loff_t ofs, uint64_t len)
return cfi_varsize_frob(mtd, do_atmel_unlock, ofs, len, NULL);
 }
 
+/*
+ * Advanced Sector Pro

Re: [PATCH] mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking

2012-12-12 Thread Stefan Roese
On 12/12/2012 04:25 PM, Artem Bityutskiy wrote:
> On Mon, 2012-12-10 at 19:40 +0100, Stefan Roese wrote:
>> On 12/10/2012 04:00 PM, Artem Bityutskiy wrote:
>>> On Fri, 2012-12-07 at 08:22 +0100, Stefan Roese wrote:
>>>> +   /*
>>>> +* Wait for some time as unlocking of all sectors takes quite long
>>>> +*/
>>>> +   timeo = jiffies + (2 * HZ); /* 2s max (un)locking */
>>>
>>> Please, use msecs_to_jiffies() instead.
>>
>> Sure, thats better.
> 
> Would you please do this instead?

Yes. I was just waiting for some further comments.

>> AFAIK, chip->mutex protects the access to the chip itself. So that
>> sequences are not interrupted.
>>
>> I have to admit that I haven't looked into get_chip() so far. It seems
>> to handle a state machine. Normally (idle state) it will just fall
>> through (FL_READY).
> 
> So it looks like the idea is that you first take the mutex, then call
> get_chip() which will wait for the chip becoming really ready, and then
> you can safely use it.

Thats it.

>>
>>> Why you need to drop the mutex here?
>>
>> Not sure, that might not be necessary. Copy and past from another loop
>> in the same file.
> 
> Probably from 'get_chip()' ?

Yes, most likely.

>>> Why is it not an ABBA deadlock to do this:
>>>
>>> Task 1: In the loop above, has chip locked, doing
>>> mutex_lock(&chip->mutex);
>>>
>>> Task 2: done mutex_lock(&chip->mutex), now doing
>>> ret = get_chip(map, chip, adr + chip->start, FL_LOCKING);
>>
>> I don't see two different locks/mutexes (only A) here. As get_chip()
>> does no request any real mutex. Please correct me if I'm wrong.
> 
> Right, there is indeed no deadlock.
> 
>> In many other places UDELAY() is called:
>>
>> #define UDELAY(map, chip, adr, usec)  \
>> do {  \
>>  mutex_unlock(&chip->mutex);  \
>>  cfi_udelay(usec);  \
>>  mutex_lock(&chip->mutex);  \
>> } while (0)
> 
> Why not to use this as well then for consistency?

Okay, will do.

I'll send a new patch version today.

Thanks for the review,
Stefan

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking

2012-12-10 Thread Stefan Roese
On 12/10/2012 04:00 PM, Artem Bityutskiy wrote:
> On Fri, 2012-12-07 at 08:22 +0100, Stefan Roese wrote:
>> +   /*
>> +* Wait for some time as unlocking of all sectors takes quite long
>> +*/
>> +   timeo = jiffies + (2 * HZ); /* 2s max (un)locking */
> 
> Please, use msecs_to_jiffies() instead.

Sure, thats better.

>> +   for (;;) {
>> +   if (chip_ready(map, adr))
>> +   break;
>> +
>> +   if (time_after(jiffies, timeo)) {
>> +   printk(KERN_ERR "Waiting for chip to be ready timed 
>> out.\n");
>> +   ret = -EIO;
>> +   break;
>> +   }
>> +   mutex_unlock(&chip->mutex);
>> +   cfi_udelay(1);
>> +   mutex_lock(&chip->mutex);
>> +   } 
> 
> Would you please educate me a bit and explain what is protected by
> 'chip->mutex' and by 'get_chip()'.

AFAIK, chip->mutex protects the access to the chip itself. So that
sequences are not interrupted.

I have to admit that I haven't looked into get_chip() so far. It seems
to handle a state machine. Normally (idle state) it will just fall
through (FL_READY).

> Why you need to drop the mutex here?

Not sure, that might not be necessary. Copy and past from another loop
in the same file.

> Why is it not an ABBA deadlock to do this:
> 
> Task 1: In the loop above, has chip locked, doing
> mutex_lock(&chip->mutex);
> 
> Task 2: done mutex_lock(&chip->mutex), now doing
> ret = get_chip(map, chip, adr + chip->start, FL_LOCKING);

I don't see two different locks/mutexes (only A) here. As get_chip()
does no request any real mutex. Please correct me if I'm wrong.

In many other places UDELAY() is called:

#define UDELAY(map, chip, adr, usec)  \
do {  \
mutex_unlock(&chip->mutex);  \
cfi_udelay(usec);  \
mutex_lock(&chip->mutex);  \
} while (0)

So dropping this lock seems to be quite common in this driver.

Thanks,
Stefan

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH] mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking

2012-12-06 Thread Stefan Roese
Currently cfi_cmdset_0002.c does not support PPB locking of sectors. This
patch adds support for this locking/unlocking mechanism. It is needed on
some platforms, since newer U-Boot versions do support this PPB locking
and protect for example their environment sector(s) this way.

This PPB locking/unlocking will be enabled for all devices supported by
cfi_cmdset_0002 reporting 8 in the CFI word 0x49 (Sector Protect/Unprotect
scheme).

Please note that PPB locking does support sector-by-sector locking. But
the whole chip can only be unlocked together. So unlocking one sector
will automatically unlock all sectors of this device. Because of this
chip limitation, the PPB unlocking function saves the current locking
status of all sectors before unlocking the whole device. After unlocking
the saved locking status is re-configured. This way only the addressed
sectors will be unlocked.

To selectively enable this advanced sector protection mechanism, the
device-tree property "use-advanced-sector-protection" has been created.
To enable support for this locking this property needs to be present in the
flash DT node. E.g.:

nor_flash@0,0 {
compatible = "amd,s29gl256n", "cfi-flash";
bank-width = <2>;
use-advanced-sector-protection;
...

Tested with Spanion S29GL512S10THI and Micron JS28F512M29EWx flash
devices.

Signed-off-by: Stefan Roese 
Cc: Holger Brunck 
Cc: Artem Bityutskiy 
---
 .../devicetree/bindings/mtd/mtd-physmap.txt|   3 +
 drivers/mtd/chips/cfi_cmdset_0002.c| 211 +
 drivers/mtd/maps/physmap_of.c  |   1 +
 include/linux/mtd/map.h|   1 +
 4 files changed, 216 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt 
b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
index 94de19b..15902b8 100644
--- a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
+++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
@@ -23,6 +23,9 @@ file systems on embedded devices.
unaligned accesses as implemented in the JFFS2 code via memcpy().
By defining "no-unaligned-direct-access", the flash will not be
exposed directly to the MTD users (e.g. JFFS2) any more.
+ - use-advanced-sector-protection: boolean to enable support for the
+   advanced sector protection (Spansion: PPB - Persistent Protection
+   Bits) locking.
 
 For JEDEC compatible devices, the following additional properties
 are defined:
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c 
b/drivers/mtd/chips/cfi_cmdset_0002.c
index 5ff5c4a..b4f314b 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -74,6 +75,10 @@ static void put_chip(struct map_info *map, struct flchip 
*chip, unsigned long ad
 static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
 static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
 
+static int cfi_ppb_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
+static int cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
+static int cfi_ppb_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len);
+
 static struct mtd_chip_driver cfi_amdstd_chipdrv = {
.probe  = NULL, /* Not usable directly */
.destroy= cfi_amdstd_destroy,
@@ -496,6 +501,7 @@ static void cfi_fixup_m29ew_delay_after_resume(struct 
cfi_private *cfi)
 struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
 {
struct cfi_private *cfi = map->fldrv_priv;
+   struct device_node *np = map->device_node;
struct mtd_info *mtd;
int i;
 
@@ -570,6 +576,15 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int 
primary)
cfi_tell_features(extp);
 #endif
 
+   if (np && of_property_read_bool(
+   np, "use-advanced-sector-protection")
+   && extp->BlkProtUnprot == 8) {
+   printk(KERN_INFO "  Advanced Sector Protection 
(PPB Locking) supported\n");
+   mtd->_lock = cfi_ppb_lock;
+   mtd->_unlock = cfi_ppb_unlock;
+   mtd->_is_locked = cfi_ppb_is_locked;
+   }
+
bootloc = extp->TopBottom;
if ((bootloc < 2) || (bootloc > 5)) {
printk(KERN_WARNING "%s: CFI contains 
unrecognised boot "
@@ -2160,6 +2175,202 @@ static int cfi_atmel_unlock(struct mtd_info *mtd, 
loff_t ofs, uint64_t len)
return cfi_varsize_frob(mtd, do_atmel_unlock, ofs, len, NULL);
 }
 
+/*
+ * Advanced Sector Protection - PPB (Persistent Protection Bit) locking
+ */

[PATCH v2] mtd: physmap_of: Add "no-unaligned-direct-access" DT property

2012-08-17 Thread Stefan Roese
On some platforms (e.g. MPC5200) a direct 1:1 mapping may cause
problems with JFFS2 usage, as the local bus (LPB) doesn't support
unaligned accesses as implemented in the JFFS2 code via memcpy().
By defining "no-unaligned-direct-access", the flash will not be
exposed directly to the MTD users (e.g. JFFS2) any more.

Signed-off-by: Stefan Roese 
Cc: Stephan Gatzka 
Cc: Anatolij Gustschin 
Cc: Albrecht Dress 
Cc: Artem Bityutskiy 
Cc: David Woodhouse 
---
v2:
- Changed "map-indirect" to "no-unaligned-direct-access" because of
  David's comments.

 Documentation/devicetree/bindings/mtd/mtd-physmap.txt |  7 +++
 drivers/mtd/maps/physmap_of.c | 14 ++
 2 files changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt 
b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
index a63c2bd7..94de19b 100644
--- a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
+++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
@@ -16,6 +16,13 @@ file systems on embedded devices.
  - #address-cells, #size-cells : Must be present if the device has
sub-nodes representing partitions (see below).  In this case
both #address-cells and #size-cells must be equal to 1.
+ - no-unaligned-direct-access: boolean to disable the default direct
+   mapping of the flash.
+   On some platforms (e.g. MPC5200) a direct 1:1 mapping may cause
+   problems with JFFS2 usage, as the local bus (LPB) doesn't support
+   unaligned accesses as implemented in the JFFS2 code via memcpy().
+   By defining "no-unaligned-direct-access", the flash will not be
+   exposed directly to the MTD users (e.g. JFFS2) any more.
 
 For JEDEC compatible devices, the following additional properties
 are defined:
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 2e6fb68..6f19aca 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -169,6 +169,7 @@ static int __devinit of_flash_probe(struct platform_device 
*dev)
struct mtd_info **mtd_list = NULL;
resource_size_t res_size;
struct mtd_part_parser_data ppdata;
+   bool map_indirect;
 
match = of_match_device(of_flash_match, &dev->dev);
if (!match)
@@ -192,6 +193,8 @@ static int __devinit of_flash_probe(struct platform_device 
*dev)
}
count /= reg_tuple_size;
 
+   map_indirect = of_property_read_bool(dp, "no-unaligned-direct-access");
+
err = -ENOMEM;
info = kzalloc(sizeof(struct of_flash) +
   sizeof(struct of_flash_list) * count, GFP_KERNEL);
@@ -247,6 +250,17 @@ static int __devinit of_flash_probe(struct platform_device 
*dev)
 
simple_map_init(&info->list[i].map);
 
+   /*
+* On some platforms (e.g. MPC5200) a direct 1:1 mapping
+* may cause problems with JFFS2 usage, as the local bus (LPB)
+* doesn't support unaligned accesses as implemented in the
+* JFFS2 code via memcpy(). By setting NO_XIP, the
+* flash will not be exposed directly to the MTD users
+* (e.g. JFFS2) any more.
+*/
+   if (map_indirect)
+   info->list[i].map.phys = NO_XIP;
+
if (probe_type) {
info->list[i].mtd = do_map_probe(probe_type,
 &info->list[i].map);
-- 
1.7.11.2

___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v3] staging:iio:adc: Add SPEAr ADC driver

2012-04-12 Thread Stefan Roese
This patch implements the basic single data conversion support for
the SPEAr600 SoC ADC. The register layout of SPEAr600 differs a bit
from other SPEAr SoC variants (e.g. SPEAr3xx). These differences are
handled via DT compatible testing. Resulting in a multi-arch binary.

This driver is currently tested only on SPEAr600. Future patches may add
support for other SoC variants (SPEAr3xx) and features like software
buffer or DMA.

Signed-off-by: Stefan Roese 
Acked-by: Jonathan Cameron 
Acked-by: Viresh Kumar 
Cc: Greg KH 
---
v3:
- Used devm_request_irq() instead of request_irq and removed free_irq()
- Added clk_disable() and clk_unprepare() in error path and
  spear_adc_remove()

v2:
- Minor spelling fixes pointed out by Jonathan
- Renamed scale_uv to scale_mv
- Used defines for constants (CLK_MIN, CLK_MAX)
- Used of_iomap() instead of ioremap() and platform_get_resource()
- Added clk_prepare()
- Added error checking to clk_enable()

 .../bindings/staging/iio/adc/spear-adc.txt |   26 ++
 drivers/staging/iio/adc/Kconfig|7 +
 drivers/staging/iio/adc/Makefile   |1 +
 drivers/staging/iio/adc/spear_adc.c|  447 
 4 files changed, 481 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt
 create mode 100644 drivers/staging/iio/adc/spear_adc.c

diff --git a/Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt 
b/Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt
new file mode 100644
index 000..02ea23a
--- /dev/null
+++ b/Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt
@@ -0,0 +1,26 @@
+* ST SPEAr ADC device driver
+
+Required properties:
+- compatible: Should be "st,spear600-adc"
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the ADC interrupt
+- sampling-frequency: Default sampling frequency
+
+Optional properties:
+- vref-external: External voltage reference in milli-volts. If omitted
+  the internal voltage reference will be used.
+- average-samples: Number of samples to generate an average value. If
+  omitted, single data conversion will be used.
+
+Examples:
+
+   adc: adc@d820 {
+   compatible = "st,spear600-adc";
+   reg = <0xd820 0x1000>;
+   interrupt-parent = <&vic1>;
+   interrupts = <6>;
+   sampling-frequency = <500>;
+   vref-external = <2500>; /* 2.5V VRef */
+   };
diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig
index 592eabd..ec006e7 100644
--- a/drivers/staging/iio/adc/Kconfig
+++ b/drivers/staging/iio/adc/Kconfig
@@ -202,4 +202,11 @@ config LPC32XX_ADC
  touchscreen driver, so you can only select one of the two drivers
  (lpc32xx_adc or lpc32xx_ts). Provides direct access via sysfs.
 
+config SPEAR_ADC
+   tristate "ST SPEAr ADC"
+   depends on PLAT_SPEAR
+   help
+ Say yes here to build support for the integrated ADC inside the
+ ST SPEAr SoC. Provides direct access via sysfs.
+
 endmenu
diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile
index f83ab95..14e98b6 100644
--- a/drivers/staging/iio/adc/Makefile
+++ b/drivers/staging/iio/adc/Makefile
@@ -38,3 +38,4 @@ obj-$(CONFIG_ADT7310) += adt7310.o
 obj-$(CONFIG_ADT7410) += adt7410.o
 obj-$(CONFIG_AD7280) += ad7280a.o
 obj-$(CONFIG_LPC32XX_ADC) += lpc32xx_adc.o
+obj-$(CONFIG_SPEAR_ADC) += spear_adc.o
diff --git a/drivers/staging/iio/adc/spear_adc.c 
b/drivers/staging/iio/adc/spear_adc.c
new file mode 100644
index 000..bea5778
--- /dev/null
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -0,0 +1,447 @@
+/*
+ * ST SPEAr ADC driver
+ *
+ * Copyright 2012 Stefan Roese 
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../iio.h"
+#include "../sysfs.h"
+
+/*
+ * SPEAR registers definitions
+ */
+
+#define SCAN_RATE_LO(x)((x) & 0x)
+#define SCAN_RATE_HI(x)(((x) >> 0x10) & 0x)
+#define CLK_LOW(x) (((x) & 0xf) << 0)
+#define CLK_HIGH(x)(((x) & 0xf) << 4)
+
+/* Bit definitions for SPEAR_ADC_STATUS */
+#define START_CONVERSION   (1 << 0)
+#define CHANNEL_NUM(x) ((x) << 1)
+#define ADC_ENABLE (1 << 4)
+#define AVG_SAMPLE(x)  ((x) << 5)
+#define VREF_INTERNAL  (1 << 9)
+
+#define DATA_MASK  0x03ff
+#define DATA_BITS  10
+
+#define MOD_NAME "spear-adc"
+
+#define ADC_CHANNEL_NUM8
+
+#define CLK_MIN 

[PATCH v2] staging:iio:adc: Add SPEAr ADC driver

2012-04-12 Thread Stefan Roese
This patch implements the basic single data conversion support for
the SPEAr600 SoC ADC. The register layout of SPEAr600 differs a bit
from other SPEAr SoC variants (e.g. SPEAr3xx). These differences are
handled via DT compatible testing. Resulting in a multi-arch binary.

This driver is currently tested only on SPEAr600. Future patches may add
support for other SoC variants (SPEAr3xx) and features like software
buffer or DMA.

Signed-off-by: Stefan Roese 
Acked-by: Jonathan Cameron 
Cc: Greg KH 
Cc: Viresh Kumar 
---
v2:
- Minor spelling fixes pointed out by Jonathan
- Renamed scale_uv to scale_mv
- Used defines for constants (CLK_MIN, CLK_MAX)
- Used of_iomap() instead of ioremap() and platform_get_resource()
- Added clk_prepare()
- Added error checking to clk_enable()

 .../bindings/staging/iio/adc/spear-adc.txt |   26 ++
 drivers/staging/iio/adc/Kconfig|7 +
 drivers/staging/iio/adc/Makefile   |1 +
 drivers/staging/iio/adc/spear_adc.c|  444 
 4 files changed, 478 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt
 create mode 100644 drivers/staging/iio/adc/spear_adc.c

diff --git a/Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt 
b/Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt
new file mode 100644
index 000..02ea23a
--- /dev/null
+++ b/Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt
@@ -0,0 +1,26 @@
+* ST SPEAr ADC device driver
+
+Required properties:
+- compatible: Should be "st,spear600-adc"
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the ADC interrupt
+- sampling-frequency: Default sampling frequency
+
+Optional properties:
+- vref-external: External voltage reference in milli-volts. If omitted
+  the internal voltage reference will be used.
+- average-samples: Number of samples to generate an average value. If
+  omitted, single data conversion will be used.
+
+Examples:
+
+   adc: adc@d820 {
+   compatible = "st,spear600-adc";
+   reg = <0xd820 0x1000>;
+   interrupt-parent = <&vic1>;
+   interrupts = <6>;
+   sampling-frequency = <500>;
+   vref-external = <2500>; /* 2.5V VRef */
+   };
diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig
index 592eabd..ec006e7 100644
--- a/drivers/staging/iio/adc/Kconfig
+++ b/drivers/staging/iio/adc/Kconfig
@@ -202,4 +202,11 @@ config LPC32XX_ADC
  touchscreen driver, so you can only select one of the two drivers
  (lpc32xx_adc or lpc32xx_ts). Provides direct access via sysfs.
 
+config SPEAR_ADC
+   tristate "ST SPEAr ADC"
+   depends on PLAT_SPEAR
+   help
+ Say yes here to build support for the integrated ADC inside the
+ ST SPEAr SoC. Provides direct access via sysfs.
+
 endmenu
diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile
index f83ab95..14e98b6 100644
--- a/drivers/staging/iio/adc/Makefile
+++ b/drivers/staging/iio/adc/Makefile
@@ -38,3 +38,4 @@ obj-$(CONFIG_ADT7310) += adt7310.o
 obj-$(CONFIG_ADT7410) += adt7410.o
 obj-$(CONFIG_AD7280) += ad7280a.o
 obj-$(CONFIG_LPC32XX_ADC) += lpc32xx_adc.o
+obj-$(CONFIG_SPEAR_ADC) += spear_adc.o
diff --git a/drivers/staging/iio/adc/spear_adc.c 
b/drivers/staging/iio/adc/spear_adc.c
new file mode 100644
index 000..d5b6730
--- /dev/null
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -0,0 +1,444 @@
+/*
+ * ST SPEAr ADC driver
+ *
+ * Copyright 2012 Stefan Roese 
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../iio.h"
+#include "../sysfs.h"
+
+/*
+ * SPEAR registers definitions
+ */
+
+#define SCAN_RATE_LO(x)((x) & 0x)
+#define SCAN_RATE_HI(x)(((x) >> 0x10) & 0x)
+#define CLK_LOW(x) (((x) & 0xf) << 0)
+#define CLK_HIGH(x)(((x) & 0xf) << 4)
+
+/* Bit definitions for SPEAR_ADC_STATUS */
+#define START_CONVERSION   (1 << 0)
+#define CHANNEL_NUM(x) ((x) << 1)
+#define ADC_ENABLE (1 << 4)
+#define AVG_SAMPLE(x)  ((x) << 5)
+#define VREF_INTERNAL  (1 << 9)
+
+#define DATA_MASK  0x03ff
+#define DATA_BITS  10
+
+#define MOD_NAME "spear-adc"
+
+#define ADC_CHANNEL_NUM8
+
+#define CLK_MIN250
+#define CLK_MAX2000
+
+struct adc_regs_spear3xx {
+   u32 status;
+   u32 average;
+   u3

Re: [PATCH] staging:iio:adc: Add SPEAr ADC driver

2012-04-12 Thread Stefan Roese
On Thursday 12 April 2012 09:41:45 Viresh Kumar wrote:
> On 4/12/2012 12:33 PM, Stefan Roese wrote:
> >> > patch for devm_* variant of clk is also there.
> > 
> > Where is it? Is it already in "next"? Do you have a link for the patch?
> 
> Probably not in next till now.
> 
> https://lkml.org/lkml/2012/4/1/56

I just checked, it's not in "next". IIUC, there should be an updated patch 
version for this coming soon. So basing my patch on this one seems a bit too 
early from my point of view. Perhaps its best to update all iio drivers, once 
this devm_clk_* stuff in really available.

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] staging:iio:adc: Add SPEAr ADC driver

2012-04-12 Thread Stefan Roese
On Thursday 12 April 2012 08:12:02 Viresh Kumar wrote:
> On 4/11/2012 6:49 PM, Stefan Roese wrote:
> > +static int __devinit spear_adc_probe(struct platform_device *pdev)
> > +{
> > +   struct device_node *np = pdev->dev.of_node;
> > +   struct spear_adc_info *info;
> > +   struct resource *res;
> > +   int retval = -ENODEV;
> > +   struct iio_dev *iodev = NULL;
> > +   int irq;
> > +
> > +   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +   if (!res) {
> > +   dev_err(&pdev->dev, "failed to get platform I/O
> > memory\n"); +   retval = -EBUSY;
> > +   goto errout1;
> > +   }
> > +
> > +   iodev = iio_allocate_device(sizeof(struct spear_adc_info));
> > +   if (!iodev) {
> > +   dev_err(&pdev->dev, "failed allocating iio device\n");
> > +   retval = -ENOMEM;
> > +   goto errout1;
> > +   }
> > +
> > +   info = iio_priv(iodev);
> > +   info->np = np;
> > +
> > +   /*
> > +* SPEAr600 has a different register layout than other SPEAr
> > SoC's +* (e.g. SPEAr3xx). Let's provide two register base
> > addresses +* to support multi-arch kernels.
> > +*/
> > +   info->adc_base_spear6xx = ioremap(res->start,
> > resource_size(res)); +   if (!info->adc_base_spear6xx) {
> > +   dev_err(&pdev->dev, "failed mapping memory\n");
> > +   retval = -EBUSY;
> > +   goto errout2;
> > +   }
> 
> This must be a DT only driver and so you can use of_iomap() instead of
> ioremap() and platform_get_resource()

Yes, thanks for spotting.
 
> > +   info->adc_base_spear3xx =
> > +   (struct adc_regs_spear3xx *)info->adc_base_spear6xx;
> > +
> > +   info->clk = clk_get(&pdev->dev, NULL);
> > +   if (IS_ERR(info->clk)) {
> > +   dev_err(&pdev->dev, "failed getting clock\n");
> > +   goto errout3;
> > +   }
> 
> patch for devm_* variant of clk is also there.

Where is it? Is it already in "next"? Do you have a link for the patch?

> > +   clk_enable(info->clk);
> 
> clk_prepare() is required now, before enable.

Ahh, I didn't follow the clk updates lately. Will update.
 
> > +
> > +   irq = platform_get_irq(pdev, 0);
> > +   if ((irq < 0) || (irq >= NR_IRQS)) {
> > +   dev_err(&pdev->dev, "failed getting interrupt
> > resource\n"); +   retval = -EINVAL;
> > +   goto errout4;
> > +   }
> > +
> > +   retval = request_irq(irq, spear_adc_isr, 0, MOD_NAME, info);
> > +   if (retval < 0) {
> > +   dev_err(&pdev->dev, "failed requesting interrupt\n");
> > +   goto errout4;
> > +   }
> > +
> 
> can use devm_* variants wherever possible.

Okay.

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] staging:iio:adc: Add SPEAr ADC driver

2012-04-11 Thread Stefan Roese
On Wednesday 11 April 2012 15:40:52 Jonathan Cameron wrote:
> On 4/11/2012 2:19 PM, Stefan Roese wrote:
> > This patch implements the basic single data conversion support for
> > the SPEAr600 SoC ADC. The register layout of SPEAr600 differs a bit
> > from other SPEAr SoC variants (e.g. SPEAr3xx). These differences are
> > handled via DT compatible testing. Resuling in a multi-arch binary.
> 
> Resulting
> 
> > This driver is currently tested only on SPEAr600. Futur patches may add
> > support for other SoC variants (SPEAr3xx) and features like software
> > buffer or DMA.
> 
> Future
> 
> Ironically that's about it wrt to comments. Couple of totally trivial
> bits inline.
> Basically I'm happy, so if/when someone acks the device tree side of
> things, please
> clean up the trivial bits and send on to GregKH.
> 
> Nice short, clean driver.  The small line count lured me into reviewing
> it ahead of
> some others in my review pile!

Jonathan, thanks for the quick review. I'll address you comments and send an 
updated patch shortly.

Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH] staging:iio:adc: Add SPEAr ADC driver

2012-04-11 Thread Stefan Roese
This patch implements the basic single data conversion support for
the SPEAr600 SoC ADC. The register layout of SPEAr600 differs a bit
from other SPEAr SoC variants (e.g. SPEAr3xx). These differences are
handled via DT compatible testing. Resuling in a multi-arch binary.

This driver is currently tested only on SPEAr600. Futur patches may add
support for other SoC variants (SPEAr3xx) and features like software
buffer or DMA.

Signed-off-by: Stefan Roese 
Cc: Jonathan Cameron 
Cc: Viresh Kumar 
---
 .../bindings/staging/iio/adc/spear-adc.txt |   26 ++
 drivers/staging/iio/adc/Kconfig|7 +
 drivers/staging/iio/adc/Makefile   |1 +
 drivers/staging/iio/adc/spear_adc.c|  439 
 4 files changed, 473 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt
 create mode 100644 drivers/staging/iio/adc/spear_adc.c

diff --git a/Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt 
b/Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt
new file mode 100644
index 000..02ea23a
--- /dev/null
+++ b/Documentation/devicetree/bindings/staging/iio/adc/spear-adc.txt
@@ -0,0 +1,26 @@
+* ST SPEAr ADC device driver
+
+Required properties:
+- compatible: Should be "st,spear600-adc"
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the ADC interrupt
+- sampling-frequency: Default sampling frequency
+
+Optional properties:
+- vref-external: External voltage reference in milli-volts. If omitted
+  the internal voltage reference will be used.
+- average-samples: Number of samples to generate an average value. If
+  omitted, single data conversion will be used.
+
+Examples:
+
+   adc: adc@d820 {
+   compatible = "st,spear600-adc";
+   reg = <0xd820 0x1000>;
+   interrupt-parent = <&vic1>;
+   interrupts = <6>;
+   sampling-frequency = <500>;
+   vref-external = <2500>; /* 2.5V VRef */
+   };
diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig
index 592eabd..ec006e7 100644
--- a/drivers/staging/iio/adc/Kconfig
+++ b/drivers/staging/iio/adc/Kconfig
@@ -202,4 +202,11 @@ config LPC32XX_ADC
  touchscreen driver, so you can only select one of the two drivers
  (lpc32xx_adc or lpc32xx_ts). Provides direct access via sysfs.
 
+config SPEAR_ADC
+   tristate "ST SPEAr ADC"
+   depends on PLAT_SPEAR
+   help
+ Say yes here to build support for the integrated ADC inside the
+ ST SPEAr SoC. Provides direct access via sysfs.
+
 endmenu
diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile
index f83ab95..14e98b6 100644
--- a/drivers/staging/iio/adc/Makefile
+++ b/drivers/staging/iio/adc/Makefile
@@ -38,3 +38,4 @@ obj-$(CONFIG_ADT7310) += adt7310.o
 obj-$(CONFIG_ADT7410) += adt7410.o
 obj-$(CONFIG_AD7280) += ad7280a.o
 obj-$(CONFIG_LPC32XX_ADC) += lpc32xx_adc.o
+obj-$(CONFIG_SPEAR_ADC) += spear_adc.o
diff --git a/drivers/staging/iio/adc/spear_adc.c 
b/drivers/staging/iio/adc/spear_adc.c
new file mode 100644
index 000..ce518bc
--- /dev/null
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -0,0 +1,439 @@
+/*
+ * ST SPEAr ADC driver
+ *
+ * Copyright 2012 Stefan Roese 
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../iio.h"
+#include "../sysfs.h"
+
+/*
+ * SPEAR registers definitions
+ */
+
+#define SCAN_RATE_LO(x)((x) & 0x)
+#define SCAN_RATE_HI(x)(((x) >> 0x10) & 0x)
+#define CLK_LOW(x) (((x) & 0xf) << 0)
+#define CLK_HIGH(x)(((x) & 0xf) << 4)
+
+/* Bit definitions for SPEAR_ADC_STATUS */
+#define START_CONVERSION   (1 << 0)
+#define CHANNEL_NUM(x) ((x) << 1)
+#define ADC_ENABLE (1 << 4)
+#define AVG_SAMPLE(x)  ((x) << 5)
+#define VREF_INTERNAL  (1 << 9)
+
+#define DATA_MASK  0x03ff
+#define DATA_BITS  10
+
+#define MOD_NAME "spear-adc"
+
+#define ADC_CHANNEL_NUM8
+
+struct adc_regs_spear3xx {
+   u32 status;
+   u32 average;
+   u32 scan_rate;
+   u32 clk;/* Not avail for 1340 & 1310 */
+   u32 ch_ctrl[ADC_CHANNEL_NUM];
+   u32 ch_data[ADC_CHANNEL_NUM];
+};
+
+struct chan_data {
+   u32 lsb;
+   u32 msb;
+};
+
+struct adc_regs_spear6xx {
+   u32 status;
+   u32 pad[2];
+   u32 clk;
+   u32 ch_ctrl[ADC_CHANNEL_NUM];
+   struct chan_data ch_data[ADC_CHANNEL_NUM];
+

Re: [PATCH] rtc/spear: Add Device Tree probing capability

2012-03-26 Thread Stefan Roese
On Monday 26 March 2012 11:54:22 Viresh Kumar wrote:
> SPEAr platforms now support DT and so must convert all drivers support DT.
> This patch adds DT probing support for rtc and updates its documentation
> too.
> 
> Signed-off-by: Viresh Kumar 
> ---
>  Documentation/devicetree/bindings/rtc/spear-rtc.txt |   18
> ++ drivers/rtc/rtc-spear.c |  
> 10 ++ 2 files changed, 28 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/rtc/spear-rtc.txt
> 
> diff --git a/Documentation/devicetree/bindings/rtc/spear-rtc.txt
> b/Documentation/devicetree/bindings/rtc/spear-rtc.txt new file mode 100644
> index 000..928410f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rtc/spear-rtc.txt
> @@ -0,0 +1,18 @@
> +* SPEAr RTC
> +
> +Required properties:
> +- compatible : "st,spear-rtc"
> +- reg : Address range of the rtc registers
> +- interrupt-parent: Should be the phandle for the interrupt controller
> +  that services interrupts for this device
> +- interrupt: Should contain the rtc interrupt number
> +
> +Example:
> +
> + rtc@fc00 {
> + compatible = "st,spear-rtc";

With Rob's comments in mind, wouldn't it be better to use a more specific 
compatible property? Should we stick with "st,spear600-rtc"? Or use "st-
spear300-rtc" as "oldest" SoC variant?

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] USB: Add DT probing support to ehci-spear and ohci-spear

2012-03-23 Thread Stefan Roese
Hi Viresh,

On Friday 23 March 2012 04:48:05 Viresh Kumar wrote:
> On 3/22/2012 9:20 PM, Stefan Roese wrote:
> > +static struct of_device_id spear_ohci_id_table[] __devinitdata = {
> > +   { .compatible = "st,spear600-ohci", },
> 
> Hi Stefan,
> 
> I have this question for other drivers (fsmc, stmmac...) as well:
> Why do we name it spear600-ohci and not spear-ohci?
> Because i believe we have same version of USB on all SPEAr SoCs.

There could be differences between the IP cores integrated into the SoCs. I 
only tested on spear600, so thats what I integrated into the drivers. While 
supporting more SoCs (SPEAr300 etc) to those drivers, you should add the 
specific compatible properties to the lists.

If the IP core doesn't differ between those SoCs, then it might make sense to 
change this property to something more general, like "st,spear-ohci" (etc). 
Not 100% sure though. Other DT experts might have more insight here.

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH] USB: Add DT probing support to ehci-spear and ohci-spear

2012-03-22 Thread Stefan Roese
This patch adds support to configure the SPEAr EHCI & OHCI driver via
device-tree instead of platform_data.

Signed-off-by: Stefan Roese 
Cc: Viresh Kumar 
---
 .../devicetree/bindings/usb/spear-usb.txt  |   39 
 drivers/usb/host/ehci-spear.c  |   32 +---
 drivers/usb/host/ohci-spear.c  |   32 +---
 3 files changed, 91 insertions(+), 12 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/spear-usb.txt

diff --git a/Documentation/devicetree/bindings/usb/spear-usb.txt 
b/Documentation/devicetree/bindings/usb/spear-usb.txt
new file mode 100644
index 000..f8a464a
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/spear-usb.txt
@@ -0,0 +1,39 @@
+ST SPEAr SoC USB controllers:
+-
+
+EHCI:
+-
+
+Required properties:
+- compatible: "st,spear600-ehci"
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the EHCI interrupt
+
+Example:
+
+   ehci@e180 {
+   compatible = "st,spear600-ehci", "usb-ehci";
+   reg = <0xe180 0x1000>;
+   interrupt-parent = <&vic1>;
+   interrupts = <27>;
+   };
+
+
+OHCI:
+-
+
+Required properties:
+- compatible: "st,spear600-ohci"
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the OHCI interrupt
+
+Example:
+
+   ohci@e190 {
+   compatible = "st,spear600-ohci", "usb-ohci";
+   reg = <0xe180 0x1000>;
+   interrupt-parent = <&vic1>;
+   interrupts = <26>;
+   };
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index 6e92855..2e3c89a 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -168,6 +169,8 @@ static int ehci_spear_drv_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend,
ehci_spear_drv_resume);
 
+static u64 spear_ehci_dma_mask = DMA_BIT_MASK(32);
+
 static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
 {
struct usb_hcd *hcd ;
@@ -175,12 +178,9 @@ static int spear_ehci_hcd_drv_probe(struct platform_device 
*pdev)
struct resource *res;
struct clk *usbh_clk;
const struct hc_driver *driver = &ehci_spear_hc_driver;
-   int *pdata = pdev->dev.platform_data;
int irq, retval;
char clk_name[20] = "usbh_clk";
-
-   if (pdata == NULL)
-   return -EFAULT;
+   static int instance = -1;
 
if (usb_disabled())
return -ENODEV;
@@ -191,8 +191,22 @@ static int spear_ehci_hcd_drv_probe(struct platform_device 
*pdev)
goto fail_irq_get;
}
 
-   if (*pdata >= 0)
-   sprintf(clk_name, "usbh.%01d_clk", *pdata);
+   /*
+* Right now device-tree probed devices don't get dma_mask set.
+* Since shared usb code relies on it, set it here for now.
+* Once we have dma capability bindings this can go away.
+*/
+   if (!pdev->dev.dma_mask)
+   pdev->dev.dma_mask = &spear_ehci_dma_mask;
+
+   /*
+* Increment the device instance, when probing via device-tree
+*/
+   if (pdev->id < 0)
+   instance++;
+   else
+   instance = pdev->id;
+   sprintf(clk_name, "usbh.%01d_clk", instance);
 
usbh_clk = clk_get(NULL, clk_name);
if (IS_ERR(usbh_clk)) {
@@ -277,6 +291,11 @@ static int spear_ehci_hcd_drv_remove(struct 
platform_device *pdev)
return 0;
 }
 
+static struct of_device_id spear_ehci_id_table[] __devinitdata = {
+   { .compatible = "st,spear600-ehci", },
+   { },
+};
+
 static struct platform_driver spear_ehci_hcd_driver = {
.probe  = spear_ehci_hcd_drv_probe,
.remove = spear_ehci_hcd_drv_remove,
@@ -285,6 +304,7 @@ static struct platform_driver spear_ehci_hcd_driver = {
.name = "spear-ehci",
.bus = &platform_bus_type,
.pm = &ehci_spear_pm_ops,
+   .of_match_table = of_match_ptr(spear_ehci_id_table),
}
 };
 
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index 95c1648..eb4640b 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 struct spear_ohci {
struct ohci_hcd ohci;
@@ -90,6 +91,8 @@ static const struct hc_driver ohci_spear_hc_driver = {
.start_po

Re: [PATCH 2/2] MTD: Add device-tree support to spear_smi

2012-03-21 Thread Stefan Roese
Hi Artem,

On Friday 16 March 2012 11:42:11 Stefan Roese wrote:
> This patch adds support to configure the SPEAr SMI driver via
> device-tree instead of platform_data.

I noticed that you pushed the first part of this patch:

[PATCH 1/2] MTD: spear_smi: Remove default partition information from driver

into l2-mtd.git. What's do plan for this patch?

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v5] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-16 Thread Stefan Roese
This patch adds a generic target for SPEAr600 board that can be
configured via the device-tree. Currently the following devices
are supported via the devicetree:

- VIC interrupts
- PL011 UART
- PL061 GPIO
- Synopsys DW I2C
- Synopsys DW ethernet

Other peripheral devices (e.g. SMI flash, FSMC NAND flash etc) will
follow in later patches.

Only the spear600-evb is currently supported. Other SPEAr600
based boards will follow later.

Since the current mainline SPEAr600 code only supports the SPEAr600
evaluation board, with nearly zero peripheral devices (only UART
and GPIO), it makes sense to switch over to DT based configuration
completely now. So this patch also removes all non-DT stuff, mainly
platform device data. The files spear600.c and spear600_evb.c are
removed completely.

Signed-off-by: Stefan Roese 
Acked-by: Viresh Kumar 
Cc: Arnd Bergmann 
Cc: Jean-Christophe PLAGNIOL-VILLARD 
---
v5:
- Disabled all non-core devices in spear600.dtsi
- Enabled used devices in spear600-evb.dts
- Added values to ranges property for busses

v4:
- Added memory node to all dts/dtsi files
- Reorganizes bus topology in the dtsi file, to match the
  real SoC layout

v3:
- Removed non-DT SPEAr600 board support completely
- Removed OF_DEV_AUXDATA and changed clkdev instead, since we
  don't support non-DT targets any more
- Changed gmac0 -> gmac etc for single instance devices in the
  dts
- Added max memory size to memory node (instead of 0)
- Dropped mac-address property
- Removed some headers from spear6xx.c

v2:
- Added DT support to spear6xx.c instead of creating board-dt.c
- Removed UART (PL011) and GPIO (PL061) platform data for
  devicetree board port. This works now via DT probing
- Added OF_DEV_AUXDATA for clock device name matching for some
  device drivers
- Removed sper600.c file completely
- Added DW I2C and ethernet nodes to the dts files
- Added other DT nodes (SMI, FSMC, ECHI, OHCI), currently disabled
  since the corresponding device drivers don't support DT probing
- Removed Linaro/FSL copyright notice from SPEAr DT files (copy-paste cruft)
- Many smaller modification to the dts/dtsi files
- Changed Documentation/devicetree/bindings/arm/spear.txt to match
  the changed bindings


 Documentation/devicetree/bindings/arm/spear.txt |8 ++
 arch/arm/boot/dts/spear600-evb.dts  |   47 ++
 arch/arm/boot/dts/spear600.dtsi |  174 +++
 arch/arm/mach-spear6xx/Kconfig  |7 +-
 arch/arm/mach-spear6xx/Makefile |6 -
 arch/arm/mach-spear6xx/clock.c  |   14 +-
 arch/arm/mach-spear6xx/spear600.c   |   25 
 arch/arm/mach-spear6xx/spear600_evb.c   |   54 ---
 arch/arm/mach-spear6xx/spear6xx.c   |  132 +
 9 files changed, 276 insertions(+), 191 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/spear.txt
 create mode 100644 arch/arm/boot/dts/spear600-evb.dts
 create mode 100644 arch/arm/boot/dts/spear600.dtsi
 delete mode 100644 arch/arm/mach-spear6xx/spear600.c
 delete mode 100644 arch/arm/mach-spear6xx/spear600_evb.c

diff --git a/Documentation/devicetree/bindings/arm/spear.txt 
b/Documentation/devicetree/bindings/arm/spear.txt
new file mode 100644
index 000..f8e54f0
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/spear.txt
@@ -0,0 +1,8 @@
+ST SPEAr Platforms Device Tree Bindings
+---
+
+Boards with the ST SPEAr600 SoC shall have the following properties:
+
+Required root node property:
+
+compatible = "st,spear600";
diff --git a/arch/arm/boot/dts/spear600-evb.dts 
b/arch/arm/boot/dts/spear600-evb.dts
new file mode 100644
index 000..636292e
--- /dev/null
+++ b/arch/arm/boot/dts/spear600-evb.dts
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2012 Stefan Roese 
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+/include/ "spear600.dtsi"
+
+/ {
+   model = "ST SPEAr600 Evaluation Board";
+   compatible = "st,spear600-evb", "st,spear600";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   memory {
+   device_type = "memory";
+   reg = <0 0x1000>;
+   };
+
+   ahb {
+   gmac: ethernet@e080 {
+   phy-mode = "gmii";
+   status = "okay";
+   };
+
+   apb {
+   serial@d000 {
+   status = "okay";
+   };
+
+   serial@d008 {
+   status = "okay&q

Re: [PATCH v4] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-16 Thread Stefan Roese
On Friday 16 March 2012 13:52:54 Arnd Bergmann wrote:
> On Friday 16 March 2012, Stefan Roese wrote:
> > > I actually like to see the devices in there, and it already helped
> > > figure out that there are two buses instead of just one. Maybe we
> > > can agree on putting them in the file but commenting them out using
> > > /* */ with an added notice that they will get enabled once we have
> > > bindings?
> > 
> > It would be great to have a decision on this. I'm leaving for a short
> > vacation in a few hours and would like to have the new (hopefully final)
> > patch out before that.
> 
> It's not a show-stopper for me either way, your patches look great.

Thanks Arnd.

I'll leave the devices included then, and still disabled. Stay tuned...

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v4] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-16 Thread Stefan Roese
On Friday 16 March 2012 13:14:35 Arnd Bergmann wrote:
> On Friday 16 March 2012, Stefan Roese wrote:
> > v4:
> > - Added memory node to all dts/dtsi files
> > - Reorganizes bus topology in the dtsi file, to match the
> > 
> >   real SoC layout
> 
> Looks good.
> 
> > +
> > +   ahb {
> > +   #address-cells = <1>;
> > +   #size-cells = <1>;
> > +   compatible = "simple-bus";
> > +   ranges;
> > +
> > +   vic0: interrupt-controller@f110 {
> > +   compatible = "arm,pl190-vic";
> > +   interrupt-controller;
> > +   reg = <0xf110 0x1000>;
> > +   #interrupt-cells = <1>;
> > +   };
> > +
> > ...
> > +   apb {
> > +   #address-cells = <1>;
> > +   #size-cells = <1>;
> > +   compatible = "simple-bus";
> > +   ranges;
> > +
> > +   serial@d000 {
> > +   compatible = "arm,pl011", "arm,primecell";
> > +   reg = <0xd000 0x1000>;
> > +   interrupt-parent = <&vic0>;
> > +   interrupts = <24>;
> > +   };
> > ...
> > +   };
> > +   };
> > +};
> 
> I would prefer to see non-empty ranges properties here. I expected the
> buses to be contiguous address ranges per bus, but apparently that
> is not the case -- you have 0xd... and 0xf... on both of them.

Yes, Its quite ugly.
 
> The simplest ranges property would be to have in the ahb node:
> 
>   ranges = <0xd000 0xd000 0x3000>;
> 
> Which just means that the bus is limited to those addresses (if that is
> indeed the case -- I don't know much about ahb and apb).

Okay, I'll add those ranges. Even though I personally don't find it more 
descriptive this way.

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v4] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-16 Thread Stefan Roese
On Friday 16 March 2012 13:09:18 Arnd Bergmann wrote:
> On Friday 16 March 2012, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 10:30 Fri 16 Mar , Stefan Roese wrote:
> > > This patch adds a generic target for SPEAr600 board that can be
> > > configured via the device-tree. Currently the following devices
> > > are supported via the devicetree:
> > > 
> > > - VIC interrupts
> > > - PL011 UART
> > > - PL061 GPIO
> > > - Synopsys DW I2C
> > > - Synopsys DW ethernet
> > > 
> > > Other peripheral devices (e.g. SMI flash, FSMC NAND flash etc) will
> > > follow in later patches.
> > 
> > so drop USB, nand & co from the dtsi
> > 
> > this will be add later when the binding will documentated and Acked
> 
> I actually like to see the devices in there, and it already helped
> figure out that there are two buses instead of just one. Maybe we
> can agree on putting them in the file but commenting them out using
> /* */ with an added notice that they will get enabled once we have
> bindings?

It would be great to have a decision on this. I'm leaving for a short vacation 
in a few hours and would like to have the new (hopefully final) patch out 
before that.

Thanks for all your comments,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v4] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-16 Thread Stefan Roese
On Friday 16 March 2012 12:50:22 Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:30 Fri 16 Mar , Stefan Roese wrote:
> > This patch adds a generic target for SPEAr600 board that can be
> > configured via the device-tree. Currently the following devices
> > are supported via the devicetree:
> > 
> > - VIC interrupts
> > - PL011 UART
> > - PL061 GPIO
> > - Synopsys DW I2C
> > - Synopsys DW ethernet
> > 
> > Other peripheral devices (e.g. SMI flash, FSMC NAND flash etc) will
> > follow in later patches.
> 
> so drop USB, nand & co from the dtsi
> 
> this will be add later when the binding will documentated and Acked

Okay. As I described in an earlier mail, I included those devices upon Arnd's 
request. But I'll drop them for now in a new patch version.
 
> > Only the spear600-evb is currently supported. Other SPEAr600
> > based boards will follow later.
> > 
> > Since the current mainline SPEAr600 code only supports the SPEAr600
> > evaluation board, with nearly zero peripheral devices (only UART
> > and GPIO), it makes sense to switch over to DT based configuration
> > completely now. So this patch also removes all non-DT stuff, mainly
> > platform device data. The files spear600.c and spear600_evb.c are
> > removed completely.
> > 
> > Signed-off-by: Stefan Roese 
> > Cc: Viresh Kumar 
> > Cc: Arnd Bergmann 
> > Cc: Jean-Christophe PLAGNIOL-VILLARD 
> > ---
> > v4:
> > - Added memory node to all dts/dtsi files
> > - Reorganizes bus topology in the dtsi file, to match the
> > 
> >   real SoC layout
> > 
> > v3:
> > - Removed non-DT SPEAr600 board support completely
> > - Removed OF_DEV_AUXDATA and changed clkdev instead, since we
> > 
> >   don't support non-DT targets any more
> > 
> > - Changed gmac0 -> gmac etc for single instance devices in the
> > 
> >   dts
> > 
> > - Added max memory size to memory node (instead of 0)
> > - Dropped mac-address property
> > - Removed some headers from spear6xx.c
> > 
> > v2:
> > - Added DT support to spear6xx.c instead of creating board-dt.c
> > - Removed UART (PL011) and GPIO (PL061) platform data for
> > 
> >   devicetree board port. This works now via DT probing
> > 
> > - Added OF_DEV_AUXDATA for clock device name matching for some
> > 
> >   device drivers
> > 
> > - Removed sper600.c file completely
> > - Added DW I2C and ethernet nodes to the dts files
> > - Added other DT nodes (SMI, FSMC, ECHI, OHCI), currently disabled
> > 
> >   since the corresponding device drivers don't support DT probing
> > 
> > - Removed Linaro/FSL copyright notice from SPEAr DT files (copy-paste
> > cruft) - Many smaller modification to the dts/dtsi files
> > - Changed Documentation/devicetree/bindings/arm/spear.txt to match
> > 
> >   the changed bindings
> >  
> >  Documentation/devicetree/bindings/arm/spear.txt |8 ++
> >  arch/arm/boot/dts/spear600-evb.dts  |   37 +
> >  arch/arm/boot/dts/spear600.dtsi |  170
> >  +++ arch/arm/mach-spear6xx/Kconfig 
> >  |7 +-
> >  arch/arm/mach-spear6xx/Makefile |6 -
> >  arch/arm/mach-spear6xx/clock.c  |   14 +-
> >  arch/arm/mach-spear6xx/spear600.c   |   25 
> >  arch/arm/mach-spear6xx/spear600_evb.c   |   54 ---
> >  arch/arm/mach-spear6xx/spear6xx.c   |  132
> >  +- 9 files changed, 262 insertions(+), 191 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/arm/spear.txt
> >  create mode 100644 arch/arm/boot/dts/spear600-evb.dts
> >  create mode 100644 arch/arm/boot/dts/spear600.dtsi
> >  delete mode 100644 arch/arm/mach-spear6xx/spear600.c
> >  delete mode 100644 arch/arm/mach-spear6xx/spear600_evb.c
> > 
> > diff --git a/Documentation/devicetree/bindings/arm/spear.txt
> > b/Documentation/devicetree/bindings/arm/spear.txt new file mode 100644
> > index 000..f8e54f0
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/arm/spear.txt
> > @@ -0,0 +1,8 @@
> > +ST SPEAr Platforms Device Tree Bindings
> > +---
> > +
> > +Boards with the ST SPEAr600 SoC shall have the following properties:
> > +
> > +Required root node property:
> > +
> > +compatible = "st,spear600";
> > diff --git a/arch/arm/boot/dts/spear600-evb.dts
> > b/arch/arm/boot/dts/spear600-evb.dt

[PATCH 2/2] MTD: Add device-tree support to spear_smi

2012-03-16 Thread Stefan Roese
This patch adds support to configure the SPEAr SMI driver via
device-tree instead of platform_data.

Signed-off-by: Stefan Roese 
Cc: Viresh Kumar 
---
 .../devicetree/bindings/mtd/spear_smi.txt  |   31 ++
 drivers/mtd/devices/spear_smi.c|  111 +---
 include/linux/mtd/spear_smi.h  |5 +
 3 files changed, 135 insertions(+), 12 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/spear_smi.txt

diff --git a/Documentation/devicetree/bindings/mtd/spear_smi.txt 
b/Documentation/devicetree/bindings/mtd/spear_smi.txt
new file mode 100644
index 000..7248aad
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/spear_smi.txt
@@ -0,0 +1,31 @@
+* SPEAr SMI
+
+Required properties:
+- compatible : "st,spear600-smi"
+- reg : Address range of the mtd chip
+- #address-cells, #size-cells : Must be present if the device has sub-nodes
+  representing partitions.
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- clock-rate : Functional clock rate of SMI in Hz
+
+Optional properties:
+- st,smi-fast-mode : Flash supports read in fast mode
+
+Example:
+
+   smi: flash@fc00 {
+   compatible = "st,spear600-smi";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   reg = <0xfc00 0x1000>;
+   interrupt-parent = <&vic1>;
+   interrupts = <12>;
+   clock-rate = <5000>;/* 50MHz */
+
+   flash@f800 {
+   st,smi-fast-mode;
+   ...
+   };
+   };
diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
index 94c5cd9..bebce11 100644
--- a/drivers/mtd/devices/spear_smi.c
+++ b/drivers/mtd/devices/spear_smi.c
@@ -35,9 +35,8 @@
 #include 
 #include 
 #include 
-
-/* max possible slots for serial-nor flash chip in the SMI controller */
-#define MAX_NUM_FLASH_CHIP 4
+#include 
+#include 
 
 /* SMI clock rate */
 #define SMI_MAX_CLOCK_FREQ 5000 /* 50 MHz */
@@ -750,9 +749,63 @@ err_probe:
return ret;
 }
 
-static int spear_smi_setup_banks(struct platform_device *pdev, u32 bank)
+
+#ifdef CONFIG_OF
+static int __devinit spear_smi_probe_config_dt(struct platform_device *pdev,
+  struct device_node *np)
+{
+   struct spear_smi_plat_data *pdata = dev_get_platdata(&pdev->dev);
+   struct device_node *pp = NULL;
+   const __be32 *addr;
+   u32 val;
+   int len;
+   int i = 0;
+
+   if (!np)
+   return -ENODEV;
+
+   of_property_read_u32(np, "clock-rate", &val);
+   pdata->clk_rate = val;
+
+   pdata->board_flash_info = devm_kzalloc(&pdev->dev,
+  sizeof(*pdata->board_flash_info),
+  GFP_KERNEL);
+
+   /* Fill structs for each subnode (flash device) */
+   while ((pp = of_get_next_child(np, pp))) {
+   struct spear_smi_flash_info *flash_info;
+
+   flash_info = &pdata->board_flash_info[i];
+   pdata->np[i] = pp;
+
+   /* Read base-addr and size from DT */
+   addr = of_get_property(pp, "reg", &len);
+   pdata->board_flash_info->mem_base = be32_to_cpup(&addr[0]);
+   pdata->board_flash_info->size = be32_to_cpup(&addr[1]);
+
+   if (of_get_property(pp, "st,smi-fast-mode", NULL))
+   pdata->board_flash_info->fast_mode = 1;
+
+   i++;
+   }
+
+   pdata->num_flashes = i;
+
+   return 0;
+}
+#else
+static int __devinit spear_smi_probe_config_dt(struct platform_device *pdev,
+  struct device_node *np)
+{
+   return -ENOSYS;
+}
+#endif
+
+static int spear_smi_setup_banks(struct platform_device *pdev,
+u32 bank, struct device_node *np)
 {
struct spear_smi *dev = platform_get_drvdata(pdev);
+   struct mtd_part_parser_data ppdata = {};
struct spear_smi_flash_info *flash_info;
struct spear_smi_plat_data *pdata;
struct spear_snor_flash *flash;
@@ -818,11 +871,16 @@ static int spear_smi_setup_banks(struct platform_device 
*pdev, u32 bank)
dev_info(&dev->pdev->dev, ".erasesize = 0x%x(%uK)\n",
flash->mtd.erasesize, flash->mtd.erasesize / 1024);
 
+#ifndef CONFIG_OF
if (flash_info->partitions) {
parts = flash_info->partitions;
count = flash_info->nr_partitions;
}
-   ret = mtd_device_parse_register(&flash->mtd, NU

[PATCH v4] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-16 Thread Stefan Roese
This patch adds a generic target for SPEAr600 board that can be
configured via the device-tree. Currently the following devices
are supported via the devicetree:

- VIC interrupts
- PL011 UART
- PL061 GPIO
- Synopsys DW I2C
- Synopsys DW ethernet

Other peripheral devices (e.g. SMI flash, FSMC NAND flash etc) will
follow in later patches.

Only the spear600-evb is currently supported. Other SPEAr600
based boards will follow later.

Since the current mainline SPEAr600 code only supports the SPEAr600
evaluation board, with nearly zero peripheral devices (only UART
and GPIO), it makes sense to switch over to DT based configuration
completely now. So this patch also removes all non-DT stuff, mainly
platform device data. The files spear600.c and spear600_evb.c are
removed completely.

Signed-off-by: Stefan Roese 
Cc: Viresh Kumar 
Cc: Arnd Bergmann 
Cc: Jean-Christophe PLAGNIOL-VILLARD 
---
v4:
- Added memory node to all dts/dtsi files
- Reorganizes bus topology in the dtsi file, to match the
  real SoC layout

v3:
- Removed non-DT SPEAr600 board support completely
- Removed OF_DEV_AUXDATA and changed clkdev instead, since we
  don't support non-DT targets any more
- Changed gmac0 -> gmac etc for single instance devices in the
  dts
- Added max memory size to memory node (instead of 0)
- Dropped mac-address property
- Removed some headers from spear6xx.c

v2:
- Added DT support to spear6xx.c instead of creating board-dt.c
- Removed UART (PL011) and GPIO (PL061) platform data for
  devicetree board port. This works now via DT probing
- Added OF_DEV_AUXDATA for clock device name matching for some
  device drivers
- Removed sper600.c file completely
- Added DW I2C and ethernet nodes to the dts files
- Added other DT nodes (SMI, FSMC, ECHI, OHCI), currently disabled
  since the corresponding device drivers don't support DT probing
- Removed Linaro/FSL copyright notice from SPEAr DT files (copy-paste cruft)
- Many smaller modification to the dts/dtsi files
- Changed Documentation/devicetree/bindings/arm/spear.txt to match
  the changed bindings

 Documentation/devicetree/bindings/arm/spear.txt |8 ++
 arch/arm/boot/dts/spear600-evb.dts  |   37 +
 arch/arm/boot/dts/spear600.dtsi |  170 +++
 arch/arm/mach-spear6xx/Kconfig  |7 +-
 arch/arm/mach-spear6xx/Makefile |6 -
 arch/arm/mach-spear6xx/clock.c  |   14 +-
 arch/arm/mach-spear6xx/spear600.c   |   25 
 arch/arm/mach-spear6xx/spear600_evb.c   |   54 ---
 arch/arm/mach-spear6xx/spear6xx.c   |  132 +-
 9 files changed, 262 insertions(+), 191 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/spear.txt
 create mode 100644 arch/arm/boot/dts/spear600-evb.dts
 create mode 100644 arch/arm/boot/dts/spear600.dtsi
 delete mode 100644 arch/arm/mach-spear6xx/spear600.c
 delete mode 100644 arch/arm/mach-spear6xx/spear600_evb.c

diff --git a/Documentation/devicetree/bindings/arm/spear.txt 
b/Documentation/devicetree/bindings/arm/spear.txt
new file mode 100644
index 000..f8e54f0
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/spear.txt
@@ -0,0 +1,8 @@
+ST SPEAr Platforms Device Tree Bindings
+---
+
+Boards with the ST SPEAr600 SoC shall have the following properties:
+
+Required root node property:
+
+compatible = "st,spear600";
diff --git a/arch/arm/boot/dts/spear600-evb.dts 
b/arch/arm/boot/dts/spear600-evb.dts
new file mode 100644
index 000..bf706b2
--- /dev/null
+++ b/arch/arm/boot/dts/spear600-evb.dts
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012 Stefan Roese 
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+/include/ "spear600.dtsi"
+
+/ {
+   model = "ST SPEAr600 Evaluation Board";
+   compatible = "st,spear600-evb", "st,spear600";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   memory {
+   device_type = "memory";
+   reg = <0 0x1000>;
+   };
+
+   ahb {
+   gmac: ethernet@e080 {
+   phy-mode = "gmii";
+   };
+
+   apb {
+   i2c@d020 {
+   clock-frequency = <40>;
+   };
+   };
+   };
+};
diff --git a/arch/arm/boot/dts/spear600.dtsi b/arch/arm/boot/dts/spear600.dtsi
new file mode 100644
index 000..cf14762
--- /dev/null
+++ b/arch/arm/boot/dts/spear600.dtsi
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2012 Stefan Roese 
+ *
+ * The code contained herein is licensed under t

[PATCH] MTD: Add device-tree support to fsmc_nand

2012-03-16 Thread Stefan Roese
This patch adds support to configure the FSMC NAND driver (used amongst
others on SPEAr platforms) via device-tree instead of platform_data.

Signed-off-by: Stefan Roese 
Cc: Viresh Kumar 
---
 .../devicetree/bindings/mtd/fsmc-nand.txt  |   33 
 drivers/mtd/nand/fsmc_nand.c   |   57 +++-
 include/linux/mtd/fsmc.h   |4 +-
 3 files changed, 91 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/fsmc-nand.txt

diff --git a/Documentation/devicetree/bindings/mtd/fsmc-nand.txt 
b/Documentation/devicetree/bindings/mtd/fsmc-nand.txt
new file mode 100644
index 000..e2c663b
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/fsmc-nand.txt
@@ -0,0 +1,33 @@
+* FSMC NAND
+
+Required properties:
+- compatible : "st,spear600-fsmc-nand"
+- reg : Address range of the mtd chip
+- reg-names: Should contain the reg names "fsmc_regs" and "nand_data"
+- st,ale-off : Chip specific offset to ALE
+- st,cle-off : Chip specific offset to CLE
+
+Optional properties:
+- bank-width : Width (in bytes) of the device.  If not present, the width
+  defaults to 1 byte
+- nand-skip-bbtscan: Indicates the the BBT scanning should be skipped
+
+Example:
+
+   fsmc: flash@d180 {
+   compatible = "st,spear600-fsmc-nand";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   reg = <0xd180 0x1000/* FSMC Register */
+  0xd200 0x4000>;  /* NAND Base */
+   reg-names = "fsmc_regs", "nand_data";
+   st,ale-off = <0x2>;
+   st,cle-off = <0x1>;
+
+   bank-width = <1>;
+   nand-skip-bbtscan;
+
+   partition@0 {
+   ...
+   };
+   };
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index 0490182..1b8330e 100644
--- a/drivers/mtd/nand/fsmc_nand.c
+++ b/drivers/mtd/nand/fsmc_nand.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -854,6 +855,38 @@ static bool filter(struct dma_chan *chan, void *slave)
return true;
 }
 
+#ifdef CONFIG_OF
+static int __devinit fsmc_nand_probe_config_dt(struct platform_device *pdev,
+  struct device_node *np)
+{
+   struct fsmc_nand_platform_data *pdata = dev_get_platdata(&pdev->dev);
+   u32 val;
+
+   /* Set default NAND width to 8 bits */
+   pdata->width = 8;
+   if (!of_property_read_u32(np, "bank-width", &val)) {
+   if (val == 2) {
+   pdata->width = 16;
+   } else if (val != 1) {
+   dev_err(&pdev->dev, "invalid bank-width %u\n", val);
+   return -EINVAL;
+   }
+   }
+   of_property_read_u32(np, "st,ale-off", &pdata->ale_off);
+   of_property_read_u32(np, "st,cle-off", &pdata->cle_off);
+   if (of_get_property(np, "nand-skip-bbtscan", NULL))
+   pdata->options = NAND_SKIP_BBTSCAN;
+
+   return 0;
+}
+#else
+static int __devinit fsmc_nand_probe_config_dt(struct platform_device *pdev,
+  struct device_node *np)
+{
+   return -ENOSYS;
+}
+#endif
+
 /*
  * fsmc_nand_probe - Probe function
  * @pdev:   platform device structure
@@ -861,6 +894,8 @@ static bool filter(struct dma_chan *chan, void *slave)
 static int __init fsmc_nand_probe(struct platform_device *pdev)
 {
struct fsmc_nand_platform_data *pdata = dev_get_platdata(&pdev->dev);
+   struct device_node __maybe_unused *np = pdev->dev.of_node;
+   struct mtd_part_parser_data ppdata = {};
struct fsmc_nand_data *host;
struct mtd_info *mtd;
struct nand_chip *nand;
@@ -870,6 +905,16 @@ static int __init fsmc_nand_probe(struct platform_device 
*pdev)
u32 pid;
int i;
 
+   if (np) {
+   pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+   pdev->dev.platform_data = pdata;
+   ret = fsmc_nand_probe_config_dt(pdev, np);
+   if (ret) {
+   dev_err(&pdev->dev, "no platform data\n");
+   return -ENODEV;
+   }
+   }
+
if (!pdata) {
dev_err(&pdev->dev, "platform data is NULL\n");
return -EINVAL;
@@ -1113,7 +1158,8 @@ static int __init fsmc_nand_probe(struct platform_device 
*pdev)
 * Check for partition info passed
 */
host->mtd.name = "nand";
-   ret = mtd_device_parse_register(&host->mtd, NULL, NULL,
+   ppdata.of_node = np;

[PATCH v3] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-15 Thread Stefan Roese
This patch adds a generic target for SPEAr600 board that can be
configured via the device-tree. Currently the following devices
are supported via the devicetree:

- VIC interrupts
- PL011 UART
- PL061 GPIO
- Synopsys DW I2C
- Synopsys DW ethernet

Other peripheral devices (e.g. SMI flash, FSMC NAND flash etc) will
follow in later patches.

Only the spear600-evb is currently supported. Other SPEAr600
based boards will follow later.

Since the current mainline SPEAr600 code only supports the SPEAr600
evaluation board, with nearly zero peripheral devices (only UART
and GPIO), it makes sense to switch over to DT based configuration
completely now. So this patch also removes all non-DT stuff, mainly
platform device data. The files spear600.c and spear600_evb.c are
removed completely.

Signed-off-by: Stefan Roese 
Cc: Viresh Kumar 
Cc: Arnd Bergmann 
Cc: Jean-Christophe PLAGNIOL-VILLARD 
---
Arnd, I didn't add your reviewed-by, since this patch version
has changed quite a bit. Please review again. Thanks.

v3:
- Removed non-DT SPEAr600 board support completely
- Removed OF_DEV_AUXDATA and changed clkdev instead, since we
  don't support non-DT targets any more
- Changed gmac0 -> gmac etc for single instance devices in the
  dts
- Added max memory size to memory node (instead of 0)
- Dropped mac-address property
- Removed some headers from spear6xx.c

v2:
- Added DT support to spear6xx.c instead of creating board-dt.c
- Removed UART (PL011) and GPIO (PL061) platform data for
  devicetree board port. This works now via DT probing
- Added OF_DEV_AUXDATA for clock device name matching for some
  device drivers
- Removed sper600.c file completely
- Added DW I2C and ethernet nodes to the dts files
- Added other DT nodes (SMI, FSMC, ECHI, OHCI), currently disabled
  since the corresponding device drivers don't support DT probing
- Removed Linaro/FSL copyright notice from SPEAr DT files (copy-paste cruft)
- Many smaller modification to the dts/dtsi files
- Changed Documentation/devicetree/bindings/arm/spear.txt to match
  the changed bindings

 Documentation/devicetree/bindings/arm/spear.txt |8 ++
 arch/arm/boot/dts/spear600-evb.dts  |   30 +
 arch/arm/boot/dts/spear600.dtsi |  161 +++
 arch/arm/mach-spear6xx/Kconfig  |7 +-
 arch/arm/mach-spear6xx/Makefile |6 -
 arch/arm/mach-spear6xx/clock.c  |   14 +-
 arch/arm/mach-spear6xx/spear600.c   |   25 
 arch/arm/mach-spear6xx/spear600_evb.c   |   54 
 arch/arm/mach-spear6xx/spear6xx.c   |  132 +--
 9 files changed, 246 insertions(+), 191 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/spear.txt
 create mode 100644 arch/arm/boot/dts/spear600-evb.dts
 create mode 100644 arch/arm/boot/dts/spear600.dtsi
 delete mode 100644 arch/arm/mach-spear6xx/spear600.c
 delete mode 100644 arch/arm/mach-spear6xx/spear600_evb.c

diff --git a/Documentation/devicetree/bindings/arm/spear.txt 
b/Documentation/devicetree/bindings/arm/spear.txt
new file mode 100644
index 000..f8e54f0
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/spear.txt
@@ -0,0 +1,8 @@
+ST SPEAr Platforms Device Tree Bindings
+---
+
+Boards with the ST SPEAr600 SoC shall have the following properties:
+
+Required root node property:
+
+compatible = "st,spear600";
diff --git a/arch/arm/boot/dts/spear600-evb.dts 
b/arch/arm/boot/dts/spear600-evb.dts
new file mode 100644
index 000..cc594ed
--- /dev/null
+++ b/arch/arm/boot/dts/spear600-evb.dts
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012 Stefan Roese 
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+/include/ "spear600.dtsi"
+
+/ {
+   model = "ST SPEAr600 Evaluation Board";
+   compatible = "st,spear600-evb", "st,spear600";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   ahb {
+   gmac: ethernet@e080 {
+   phy-mode = "gmii";
+   };
+
+   i2c@d020 {
+   clock-frequency = <40>;
+   };
+   };
+};
diff --git a/arch/arm/boot/dts/spear600.dtsi b/arch/arm/boot/dts/spear600.dtsi
new file mode 100644
index 000..187e0eb
--- /dev/null
+++ b/arch/arm/boot/dts/spear600.dtsi
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2012 Stefan Roese 
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/lic

Re: [PATCH] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-15 Thread Stefan Roese
On Thursday 15 March 2012 10:00:27 Viresh Kumar wrote:
> On 3/15/2012 2:18 PM, Stefan Roese wrote:
> >>> > > +static const struct of_device_id vic_of_match[] __initconst = {
> >>> > > + { .compatible = "arm,pl190-vic", .data = vic_of_init, },
> >>> > > + { /* Sentinel */ }
> >>> > > +};
> >>> > > +
> >>> > > +static void __init spear6xx_dt_init_irq(void)
> >>> > > +{
> >>> > > + of_irq_init(vic_of_match);
> >>> > > +}
> >>> > > +
> >> > 
> >> > What about adding this routine in vic.c file, which can then be used
> >> > by all platforms, instead of replicating this code.
> > 
> > We can't move vic_of_match to the vic.c, since there are differences
> > between the boards using it. And only moving spear6xx_dt_init_irq()
> > (renamed of course) doesn't seem worth it.
> 
> I knew this. Actually my thought was, we have two compatible strings for
> vic: pl190 and pl192.
> 
> So, create two vic_of_match* arrays and two vic*_dt_init_irq() routines.
> That will solve the issue i believe.

I still don't think its worth it. But please feel free to send an add-on 
patch, to "clean this up".

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-15 Thread Stefan Roese
Viresh,

On Wednesday 14 March 2012 08:05:05 Viresh Kumar wrote:
> > +static const char *spear600_dt_board_compat[] = {
> > +   "st,spear600-evb",
> > +   NULL
> > +};
> > +
> > +static const struct of_device_id vic_of_match[] __initconst = {
> > +   { .compatible = "arm,pl190-vic", .data = vic_of_init, },
> > +   { /* Sentinel */ }
> > +};
> > +
> > +static void __init spear6xx_dt_init_irq(void)
> > +{
> > +   of_irq_init(vic_of_match);
> > +}
> > +
> 
> What about adding this routine in vic.c file, which can then be used
> by all platforms, instead of replicating this code.

We can't move vic_of_match to the vic.c, since there are differences between 
the boards using it. And only moving spear6xx_dt_init_irq() (renamed of 
course) doesn't seem worth it.

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v2] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-15 Thread Stefan Roese
Hi Viresh,

On Thursday 15 March 2012 09:19:54 Viresh Kumar wrote:
> Hi Stefan,
> 
> Thanks for your patch. :)

You are welcome. :)
 
> I have looked carefully at the patch, regarding addresses and irq numbers,
> and they look fine. Just few minor comments below:
> 
> On 3/14/2012 8:30 PM, Stefan Roese wrote:
> > diff --git a/arch/arm/boot/dts/spear600.dtsi
> > b/arch/arm/boot/dts/spear600.dtsi
> > 
> > +   soc {
> > +   #address-cells = <1>;
> > +   #size-cells = <1>;
> > +   compatible = "simple-bus";
> > +   ranges;
> > +
> > 
> > +
> > +   gmac0: ethernet@e080 {
> 
> There is no gmac1, so can name it gmac only.

I have no strong preference here. Not sure, what the common practice is. But I 
can remove the numbers on those single instance devices.
 
> > +   compatible = "st,spear600-gmac";
> > +   reg = <0xe080 0x8000>;
> > +   interrupt-parent = <&vic1>;
> > +   interrupts = <24 23>;
> > +   interrupt-names = "macirq", "eth_wake_irq";
> > +   mac-address = []; /* Filled in by
> > U-Boot */ +   };
> > +
> > 
> > +   fsmc0: flash@d180 {
> 
> same.
> 
> > +   status = "disabled";
> > +   compatible = "st,spear600-fsmc-nand";
> > +   #address-cells = <1>;
> > +   #size-cells = <1>;
> > +   reg = <0xd180 0x1000/* FSMC Register
> > */ +  0xd200 0x4000>;  /* NAND Base
> > */ +   reg-names = "fsmc_regs", "nand_data";
> > +   };
> > +
> > +   smi0: flash@fc00 {
> 
> same
> 
> > +   status = "disabled";
> > +   compatible = "st,spear600-smi";
> > +   #address-cells = <1>;
> > +   #size-cells = <1>;
> > +   reg = <0xfc00 0x1000>;
> > +   interrupt-parent = <&vic1>;
> > +   interrupts = <12>;
> > +   };
> > +
> > 
> > diff --git a/arch/arm/mach-spear6xx/spear600_evb.c
> > b/arch/arm/mach-spear6xx/spear600_evb.c index c6e4254..c4949aa 100644
> > --- a/arch/arm/mach-spear6xx/spear600_evb.c
> > +++ b/arch/arm/mach-spear6xx/spear600_evb.c
> > @@ -32,9 +32,6 @@ static void __init spear600_evb_init(void)
> > 
> >  {
> >  
> > unsigned int i;
> 
> Why don't we remove the devices from arrays above, which are now
> supported by DT?

This is the non-DT file (spear600_evb.c). I wanted to preserve it, so that it 
still can be built. But thinking a bit more about it, the current mainline 
SPEAr600 port only supports UART and GPIO as peripheral devices. And this 
SPEAr600 DT patch also supports those and even more devices.

So why don't we make an even bigger "cut", and remove the non-DT SPEAr600 
files/data completely now? If you give me your ACK on this, I'll squash this 
into my patch as well, resulting in a nice diffstat. ;)
 
> > -   /* call spear600 machine init function */
> > -   spear600_init();
> > -
> > 
> > /* Add Platform Devices */
> > platform_add_devices(plat_devs, ARRAY_SIZE(plat_devs));
> > 
> > diff --git a/arch/arm/mach-spear6xx/spear6xx.c
> > b/arch/arm/mach-spear6xx/spear6xx.c
> > 
> > +static const struct of_device_id vic_of_match[] __initconst = {
> > +   { .compatible = "arm,pl190-vic", .data = vic_of_init, },
> > +   { /* Sentinel */ }
> > +};
> > +
> > +static void __init spear6xx_dt_init_irq(void)
> > +{
> > +   of_irq_init(vic_of_match);
> > +}
> > +
> 
> Did you checked this out?

Not yet. Sorry, I missed it. Will check now...

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v2] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-14 Thread Stefan Roese
On Wednesday 14 March 2012 18:24:35 Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > diff --git a/arch/arm/boot/dts/spear600-evb.dts
> > > > b/arch/arm/boot/dts/spear600-evb.dts new file mode 100644
> > > > index 000..cbfda8d
> > > > --- /dev/null
> > > > +++ b/arch/arm/boot/dts/spear600-evb.dts
> > > > @@ -0,0 +1,30 @@
> > > > +/*
> > > > + * Copyright 2012 Stefan Roese 
> > > > + *
> > > > + * The code contained herein is licensed under the GNU General
> > > > Public + * License. You may obtain a copy of the GNU General Public
> > > > License + * Version 2 or later at the following locations:
> > > > + *
> > > > + * http://www.opensource.org/licenses/gpl-license.html
> > > > + * http://www.gnu.org/copyleft/gpl.html
> > > > + */
> > > > +
> > > > +/dts-v1/;
> > > > +/include/ "spear600.dtsi"
> > > > +
> > > > +/ {
> > > > +   model = "ST SPEAr600 Evaluation Board";
> > > > +   compatible = "st,spear600-evb", "st,spear600";
> > > > +   #address-cells = <1>;
> > > > +   #size-cells = <1>;
> > > 
> > > please put the mem size here
> > 
> > Might I ask why? Other *.dtsi files don't have it either.
> 
> do not expect the bootloader to put it. I t's not mandatory

But the memory node it is already present in spear600.dtsi (see below). Do we 
really need to duplicate this in the board specific dts file?
 
> > > > +
> > > > +   soc {
> > > > +   gmac0: ethernet@e080 {
> > > > +   phy-mode = "gmii";
> > > > +       };
> > > > +
> > > > +   i2c@d020 {
> > > > +   clock-frequency = <40>;
> > > > +   };
> > > > +   };
> > > > +};
> > > > diff --git a/arch/arm/boot/dts/spear600.dtsi
> > > > b/arch/arm/boot/dts/spear600.dtsi new file mode 100644
> > > > index 000..e45e58f
> > > > --- /dev/null
> > > > +++ b/arch/arm/boot/dts/spear600.dtsi
> > > > @@ -0,0 +1,162 @@
> > > > +/*
> > > > + * Copyright 2012 Stefan Roese 
> > > > + *
> > > > + * The code contained herein is licensed under the GNU General
> > > > Public + * License. You may obtain a copy of the GNU General Public
> > > > License + * Version 2 or later at the following locations:
> > > > + *
> > > > + * http://www.opensource.org/licenses/gpl-license.html
> > > > + * http://www.gnu.org/copyleft/gpl.html
> > > > + */
> > > > +
> > > > +/include/ "skeleton.dtsi"
> > > > +
> > > > +/ {
> > > > +   compatible = "st,spear600";
> > > > +
> > > > +   cpus {
> > > > +   cpu@0 {
> > > > +   compatible = "arm,arm926ejs";
> > > > +   };
> > > > +   };
> > > > +
> > > > +   memory {
> > > > +   device_type = "memory";
> > > > +   reg = <0 0>; /* Filled by U-Boot */
> > > 
> > > please put the max mem of the SoC here
> > 
> > Why? It's always updated by the bootloader. And a max. mem size (when not
> > updated to the correct mem size by the bootloader) would crash the board
> > if it is equipped with less memory.
> 
> yes but we descripbe the soc here and on the dts you reduce it
> Never expect the bootloader to update it.

Without update to real size we're doomed.
 
> It's a possibility not mandatory

Okay, I'll add the max. size here.
 
> > > > +   };
> > > > +
> > > > +   soc {
> > > 
> > > please put the name of the bus not soc
> > 
> > Okay.
> > 
> > > > +   #address-cells = <1>;
> > > > +   #size-cells = <1>;
> > > > +   compatible = "simple-bus";
> > > > +   ranges;
> > > > +
> > > > +   vic0: interrupt-controller@f110 {
> > > > +   compatible = "arm,pl190-vic";
> > > > +   interrupt-controller;
> > > > +   

Re: [PATCH v2] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-14 Thread Stefan Roese
On Wednesday 14 March 2012 17:21:52 Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 16:00 Wed 14 Mar , Stefan Roese wrote:
> > This patch adds a generic target for SPEAr600 board that can be
> > configured via the device-tree. Currently the following devices
> > are supported via the devicetree:
> > 
> > - VIC interrupts
> > - PL011 UART
> > - PL061 GPIO
> > - Synopsys DW I2C
> > - Synopsys DW ethernet
> > 
> > Other peripheral devices (e.g. SMI flash, FSMC NAND flash etc) will
> > follow in later patches.
> > 
> > Only the spear600-evb is currently supported. Other SPEAr600
> > based boards will follow later.
> > 
> > Additionally the file spear600.c is deleted. It contained only
> > one empty function and is not needed. So lets just remove it.
> > 
> > Signed-off-by: Stefan Roese 
> > Cc: Viresh Kumar 
> > Cc: Arnd Bergmann 
> > ---
> > v2:
> > - Added DT support to spear6xx.c instead of creating board-dt.c
> > - Removed UART (PL011) and GPIO (PL061) platform data for
> > 
> >   devicetree board port. This works now via DT probing
> > 
> > - Added OF_DEV_AUXDATA for clock device name matching for some
> > 
> >   device drivers
> > 
> > - Removed sper600.c file completely
> > - Added DW I2C and ethernet nodes to the dts files
> > - Added other DT nodes (SMI, FSMC, ECHI, OHCI), currently disabled
> > 
> >   since the corresponding device drivers don't support DT probing
> > 
> > - Removed Linaro/FSL copyright notice from SPEAr DT files (copy-paste
> > cruft) - Many smaller modification to the dts/dtsi files
> > - Changed Documentation/devicetree/bindings/arm/spear.txt to match
> > 
> >   the changed bindings
> >  
> >  Documentation/devicetree/bindings/arm/spear.txt |8 ++
> >  arch/arm/boot/dts/spear600-evb.dts  |   30 +
> >  arch/arm/boot/dts/spear600.dtsi |  162
> >  +++ arch/arm/mach-spear6xx/Kconfig 
> >  |7 +
> >  arch/arm/mach-spear6xx/Makefile |3 -
> >  arch/arm/mach-spear6xx/spear600.c   |   25 
> >  arch/arm/mach-spear6xx/spear600_evb.c   |3 -
> >  arch/arm/mach-spear6xx/spear6xx.c   |   69 +-
> >  8 files changed, 270 insertions(+), 37 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/arm/spear.txt
> >  create mode 100644 arch/arm/boot/dts/spear600-evb.dts
> >  create mode 100644 arch/arm/boot/dts/spear600.dtsi
> >  delete mode 100644 arch/arm/mach-spear6xx/spear600.c
> > 
> > diff --git a/Documentation/devicetree/bindings/arm/spear.txt
> > b/Documentation/devicetree/bindings/arm/spear.txt new file mode 100644
> > index 000..f8e54f0
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/arm/spear.txt
> > @@ -0,0 +1,8 @@
> > +ST SPEAr Platforms Device Tree Bindings
> > +---
> > +
> > +Boards with the ST SPEAr600 SoC shall have the following properties:
> > +
> > +Required root node property:
> > +
> > +compatible = "st,spear600";
> > diff --git a/arch/arm/boot/dts/spear600-evb.dts
> > b/arch/arm/boot/dts/spear600-evb.dts new file mode 100644
> > index 000..cbfda8d
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/spear600-evb.dts
> > @@ -0,0 +1,30 @@
> > +/*
> > + * Copyright 2012 Stefan Roese 
> > + *
> > + * The code contained herein is licensed under the GNU General Public
> > + * License. You may obtain a copy of the GNU General Public License
> > + * Version 2 or later at the following locations:
> > + *
> > + * http://www.opensource.org/licenses/gpl-license.html
> > + * http://www.gnu.org/copyleft/gpl.html
> > + */
> > +
> > +/dts-v1/;
> > +/include/ "spear600.dtsi"
> > +
> > +/ {
> > +   model = "ST SPEAr600 Evaluation Board";
> > +   compatible = "st,spear600-evb", "st,spear600";
> > +   #address-cells = <1>;
> > +   #size-cells = <1>;
> 
> please put the mem size here

Might I ask why? Other *.dtsi files don't have it either.

> > +
> > +   soc {
> > +   gmac0: ethernet@e080 {
> > +   phy-mode = "gmii";
> > +   };
> > +
> > +   i2c@d020 {
> > +   clock-frequency = <40>;
> > +   };
> > +   };
> > +};
> > diff --git a

[PATCH v2] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-14 Thread Stefan Roese
This patch adds a generic target for SPEAr600 board that can be
configured via the device-tree. Currently the following devices
are supported via the devicetree:

- VIC interrupts
- PL011 UART
- PL061 GPIO
- Synopsys DW I2C
- Synopsys DW ethernet

Other peripheral devices (e.g. SMI flash, FSMC NAND flash etc) will
follow in later patches.

Only the spear600-evb is currently supported. Other SPEAr600
based boards will follow later.

Additionally the file spear600.c is deleted. It contained only
one empty function and is not needed. So lets just remove it.

Signed-off-by: Stefan Roese 
Cc: Viresh Kumar 
Cc: Arnd Bergmann 
---
v2:
- Added DT support to spear6xx.c instead of creating board-dt.c
- Removed UART (PL011) and GPIO (PL061) platform data for
  devicetree board port. This works now via DT probing
- Added OF_DEV_AUXDATA for clock device name matching for some
  device drivers
- Removed sper600.c file completely
- Added DW I2C and ethernet nodes to the dts files
- Added other DT nodes (SMI, FSMC, ECHI, OHCI), currently disabled
  since the corresponding device drivers don't support DT probing
- Removed Linaro/FSL copyright notice from SPEAr DT files (copy-paste cruft)
- Many smaller modification to the dts/dtsi files
- Changed Documentation/devicetree/bindings/arm/spear.txt to match
  the changed bindings

 Documentation/devicetree/bindings/arm/spear.txt |8 ++
 arch/arm/boot/dts/spear600-evb.dts  |   30 +
 arch/arm/boot/dts/spear600.dtsi |  162 +++
 arch/arm/mach-spear6xx/Kconfig  |7 +
 arch/arm/mach-spear6xx/Makefile |3 -
 arch/arm/mach-spear6xx/spear600.c   |   25 
 arch/arm/mach-spear6xx/spear600_evb.c   |3 -
 arch/arm/mach-spear6xx/spear6xx.c   |   69 +-
 8 files changed, 270 insertions(+), 37 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/spear.txt
 create mode 100644 arch/arm/boot/dts/spear600-evb.dts
 create mode 100644 arch/arm/boot/dts/spear600.dtsi
 delete mode 100644 arch/arm/mach-spear6xx/spear600.c

diff --git a/Documentation/devicetree/bindings/arm/spear.txt 
b/Documentation/devicetree/bindings/arm/spear.txt
new file mode 100644
index 000..f8e54f0
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/spear.txt
@@ -0,0 +1,8 @@
+ST SPEAr Platforms Device Tree Bindings
+---
+
+Boards with the ST SPEAr600 SoC shall have the following properties:
+
+Required root node property:
+
+compatible = "st,spear600";
diff --git a/arch/arm/boot/dts/spear600-evb.dts 
b/arch/arm/boot/dts/spear600-evb.dts
new file mode 100644
index 000..cbfda8d
--- /dev/null
+++ b/arch/arm/boot/dts/spear600-evb.dts
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012 Stefan Roese 
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+/include/ "spear600.dtsi"
+
+/ {
+   model = "ST SPEAr600 Evaluation Board";
+   compatible = "st,spear600-evb", "st,spear600";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   soc {
+   gmac0: ethernet@e080 {
+   phy-mode = "gmii";
+   };
+
+   i2c@d020 {
+   clock-frequency = <40>;
+   };
+   };
+};
diff --git a/arch/arm/boot/dts/spear600.dtsi b/arch/arm/boot/dts/spear600.dtsi
new file mode 100644
index 000..e45e58f
--- /dev/null
+++ b/arch/arm/boot/dts/spear600.dtsi
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2012 Stefan Roese 
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/include/ "skeleton.dtsi"
+
+/ {
+   compatible = "st,spear600";
+
+   cpus {
+   cpu@0 {
+   compatible = "arm,arm926ejs";
+   };
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0 0>; /* Filled by U-Boot */
+   };
+
+   soc {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "simple-bus";
+   ranges;
+
+   vic0: interrupt-controller@f110 {
+   compatible = "arm,pl190-vic";
+   interrupt-controller;
+   reg = <0xf110 0x1000>;
+   #interrupt-cells = <1>;

Re: [PATCH] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-14 Thread Stefan Roese
On Wednesday 14 March 2012 14:27:00 Arnd Bergmann wrote:
> > > amba primecell devices don't actually need to register to a
> > > "compatible" property, they are probed using the primecell ID, and the
> > > device tree is just used to tell the system about memory and IRQ
> > > resources.
> > 
> > Ahh, I see. Let me see, if I can get this working...

Okay. Finally got it working. The main problem was the clock device name 
matching. Solved it via OF_DEV_AUXDATA. New patch will follow soon...
 
> I just saw that there is a patch series for pl061 that Rob Herring did at
> 
> git://sources.calxeda.com/kernel/linux.git irqdomain-for-grant
> 
> Please have a look at that branch first.

That's for GPIO interrupt support, right? I'll postpone this GPIO interrupt 
support to a later patch. This one will "only" support the plain GPIO's.
 
> > > Don't worry about the the gpio and uart devices if they are not in the
> > > first initial version. I do think that they should be done fairly soon
> > > though, before we get into most of the other devices.
> > > 
> > > It's ok if you put a lot of the other devices in the dts file though,
> > > like the ethernet device, it gives a better overview of what is
> > > actually there, even if the driver does not actually use it yet.
> > 
> > My initial idea was to push the devices once their DT support is
> > accepted. Otherwise the bindings are still not settled.
> 
> Right, that makes sense. However, you can add a property containing
> 
>   status = "disabled;
> 
> so that the device is visible in the source but no platform device gets
> generated. That would have no consequences at run time but can be helpful
> for review.

Okay, I'll add all of what I got locally. And enable only the ones that should 
be fine.

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] stmmac: Add device-tree support

2012-03-14 Thread Stefan Roese
On Wednesday 14 March 2012 14:16:56 Giuseppe CAVALLARO wrote:
> >> Concerning the latter, we support several different versions of the
> >> synopsys GMAC cores ... from 3.30 to 3.61a.
> >> 
> >> For example, stx7108 and Stx7109 have the same GMAC core (also SPEAr600
> >> IIRC).
> >> SPEAr13xx has 3.50a
> >> New ST SoC Stxh415 has the 3.60a. etc.
> > 
> > In that case, you should definitely list the exact device versions in the
> > compatible string, like:
> > 
> > compatible = "stm,spear600-gmac", "snps,dw-gmac-3.50a", "snps,dw-gmac";
> 
> looks good to me

So whats the Synopsys version for SPEAr600? 

"snps,dw-gmac-3.50a" ???

Perhaps you should add this info for all supported SoC's into the device 
driver? Or even better into the devicetree bindings Documentation?

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-14 Thread Stefan Roese
On Wednesday 14 March 2012 10:48:44 Arnd Bergmann wrote:
> > > I would suggest you convert these to DT next so you can remove the
> > > amba_devs list. Which devices are these? If they are pl061 and
> > > pl010/pl011, the binding should be really easy to do.
> > 
> > Yes. I really wanted to do that. But from a quick look at the pl011
> > driver (drivers/tty/serial/amba-pl011.c), this driver doesn't support DT
> > probing. I might have missed something here though. And ideas?
> 
> amba primecell devices don't actually need to register to a "compatible"
> property, they are probed using the primecell ID, and the device tree
> is just used to tell the system about memory and IRQ resources.

Ahh, I see. Let me see, if I can get this working...
 
> The pl061 driver has support for setting the gc.base and irq_base using
> device tree instead of the platform data and that might be enough.
> 
> > > Since there is only one upstream board file and that is for the same
> > > board, we can soon collapse all of it into the base platform support.
> > > 
> > > I think you should add all the code from this file to spear6xx.c
> > > instead of adding a new file. We can then delete the spear600.c and
> > > spear600_evb.c files once the DT support has matured.
> > 
> > Sounds like a plan. I'll rework the patch soon.
> 
> Great!
> 
> Don't worry about the the gpio and uart devices if they are not in the
> first initial version. I do think that they should be done fairly soon
> though, before we get into most of the other devices.
> 
> It's ok if you put a lot of the other devices in the dts file though,
> like the ethernet device, it gives a better overview of what is actually
> there, even if the driver does not actually use it yet.

My initial idea was to push the devices once their DT support is accepted. 
Otherwise the bindings are still not settled.

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-14 Thread Stefan Roese
Hi Arnd,

On Tuesday 13 March 2012 17:44:11 Arnd Bergmann wrote:
> On Tuesday 13 March 2012, Stefan Roese wrote:
> > This patch adds a generic target for SPEAr600 board that can be
> > configured via the device-tree. Currently only interrupts are
> > configured via device-tree. Other peripheral devices (e.g.
> > ethernet, I2C, SMI flash, FSMC NAND flash etc) will follow in
> > later patches.
> > 
> > Only the spear600-evb is currently supported. Other SPEAr600
> > based boards will follow later.
> > 
> > Signed-off-by: Stefan Roese 
> > Cc: Viresh Kumar 
> 
> Hi Stefan,
> 
> This is very cool, welcome onboard for the DT conversion with spear600!
> 
> > +static struct amba_device *amba_devs[] __initdata = {
> > +   &gpio_device[0],
> > +   &gpio_device[1],
> > +   &gpio_device[2],
> > +   &uart_device[0],
> > +   &uart_device[1],
> > +};
> 
> I would suggest you convert these to DT next so you can remove the
> amba_devs list. Which devices are these? If they are pl061 and
> pl010/pl011, the binding should be really easy to do.

Yes. I really wanted to do that. But from a quick look at the pl011 driver 
(drivers/tty/serial/amba-pl011.c), this driver doesn't support DT probing. I 
might have missed something here though. And ideas?
 
> > +static struct platform_device *plat_devs[] __initdata = {
> > +};
> 
> This could be dropped right away, because you would never
> add anything here.

Yes.
 
> > +static void __init spear600_dt_init(void)
> > +{
> > +   unsigned int i;
> > +
> > +   /* call spear600 machine init function */
> > +   spear600_init();
> 
> spear600_init currently is an empty function, I think you can
> drop that one too.

Okay.
 
> > +   /* Add Platform Devices */
> > +   platform_add_devices(plat_devs, ARRAY_SIZE(plat_devs));
> > +
> > +   /* Add Amba Devices */
> > +   for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
> > +   amba_device_register(amba_devs[i], &iomem_resource);
> 
> So although all of this can go away soon, you will have to
> add a call to of_platform_populate() here in order to add the
> devices from the device tree.

Okay.

> > +}
> > +
> > +static const char *spear600_dt_board_compat[] = {
> > +   "st,spear600-evb",
> > +   NULL
> > +};
> > +
> > +static const struct of_device_id vic_of_match[] __initconst = {
> > +   { .compatible = "arm,pl190-vic", .data = vic_of_init, },
> > +   { /* Sentinel */ }
> > +};
> > +
> > +static void __init spear6xx_dt_init_irq(void)
> > +{
> > +   of_irq_init(vic_of_match);
> > +}
> > +
> > +DT_MACHINE_START(SPEAR600_DT, "ST-SPEAR600-DT")
> > +   .map_io =   spear6xx_map_io,
> > +   .init_irq   =   spear6xx_dt_init_irq,
> > +   .handle_irq =   vic_handle_irq,
> > +   .timer  =   &spear6xx_timer,
> > +   .init_machine   =   spear600_dt_init,
> > +   .restart=   spear_restart,
> > +   .dt_compat  =   spear600_dt_board_compat,
> > +MACHINE_END
> 
> Since there is only one upstream board file and that is for the same board,
> we can soon collapse all of it into the base platform support.
> 
> I think you should add all the code from this file to spear6xx.c instead
> of adding a new file. We can then delete the spear600.c and spear600_evb.c
> files once the DT support has matured.

Sounds like a plan. I'll rework the patch soon.

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-14 Thread Stefan Roese
On Wednesday 14 March 2012 08:05:05 Viresh Kumar wrote:
> Other than Arnd's comments:
> 
> On 3/13/2012 8:17 PM, Stefan Roese wrote:
> > diff --git a/arch/arm/boot/dts/spear600-evb.dts
> > b/arch/arm/boot/dts/spear600-evb.dts new file mode 100644
> > index 000..f92d099
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/spear600-evb.dts
> > @@ -0,0 +1,23 @@
> > +/*
> > + * Copyright 2011 Freescale Semiconductor, Inc.
> > + * Copyright 2011 Linaro Ltd.
> > + *
> 
> Just for knowledge, why are above two here? Is including them suggested for
> all dts files?

I cloned this file from another dtsi file, where those copyright lines were 
present. Not sure if I need to preserve them in the new file.
 
> > + * Copyright 2012 Stefan Roese 
> > + *
> > + * The code contained herein is licensed under the GNU General Public
> > + * License. You may obtain a copy of the GNU General Public License
> > + * Version 2 or later at the following locations:
> > + *
> > + * http://www.opensource.org/licenses/gpl-license.html
> > + * http://www.gnu.org/copyleft/gpl.html
> > + */
> > +
> > 
> > 
> > diff --git a/arch/arm/mach-spear6xx/Kconfig
> > b/arch/arm/mach-spear6xx/Kconfig index ff4ae5b..f72 100644
> > --- a/arch/arm/mach-spear6xx/Kconfig
> > +++ b/arch/arm/mach-spear6xx/Kconfig
> > @@ -11,6 +11,13 @@ config BOARD_SPEAR600_EVB
> > 
> > help
> > 
> >   Supports ST SPEAr600 Evaluation Board
> > 
> > +config BOARD_SPEAR600_DT
> > +   bool "SPEAr600 generic board configured via device-tree"
> > +   select MACH_SPEAR600
> > +   select USE_OF
> > +   help
> > + Supports ST SPEAr600 boards configured via the device-tree
> > +
> > 
> >  endmenu
> >  
> >  config MACH_SPEAR600
> > 
> > diff --git a/arch/arm/mach-spear6xx/Makefile
> > b/arch/arm/mach-spear6xx/Makefile index cc1a4d8..e2d79b8 100644
> > --- a/arch/arm/mach-spear6xx/Makefile
> > +++ b/arch/arm/mach-spear6xx/Makefile
> > @@ -10,3 +10,4 @@ obj-$(CONFIG_MACH_SPEAR600) += spear600.o
> > 
> >  # spear600 boards files
> >  obj-$(CONFIG_BOARD_SPEAR600_EVB) += spear600_evb.o
> > 
> > +obj-$(CONFIG_BOARD_SPEAR600_DT) += board-dt.o
> > diff --git a/arch/arm/mach-spear6xx/board-dt.c
> > b/arch/arm/mach-spear6xx/board-dt.c new file mode 100644
> > index 000..ee4ff33
> > --- /dev/null
> > +++ b/arch/arm/mach-spear6xx/board-dt.c
> > @@ -0,0 +1,75 @@
> > +/*
> > + * arch/arm/mach-spear6xx/board-dt.c
> > + *
> > + * Generic SPEAr600 platform support
> > + *
> > + * Copyright (C) 2009 ST Microelectronics
> > + * Viresh Kumar
> 
>   ^
> Thanks for this. Can add space here between r & <.

Okay.
 
> > + *
> > + * Copyright 2012 Stefan Roese 
> > + *
> > + * This file is licensed under the terms of the GNU General Public
> > + * License version 2. This program is licensed "as is" without any
> > + * warranty of any kind, whether express or implied.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> 
> keeping header files in alphabetical order makes life easy at
> later stages. :)

Yes.
 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +static struct amba_device *amba_devs[] __initdata = {
> > +   &gpio_device[0],
> > +   &gpio_device[1],
> > +   &gpio_device[2],
> > +   &uart_device[0],
> > +   &uart_device[1],
> > +};
> > +
> > +static struct platform_device *plat_devs[] __initdata = {
> > +};
> > +
> > +static void __init spear600_dt_init(void)
> > +{
> > +   unsigned int i;
> > +
> > +   /* call spear600 machine init function */
> > +   spear600_init();
> > +
> > +   /* Add Platform Devices */
> > +   platform_add_devices(plat_devs, ARRAY_SIZE(plat_devs));
> > +
> > +   /* Add Amba Devices */
> > +   for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
> > +   amba_device_register(amba_devs[i], &iomem_resource);
> > +}
> > +
> > +static const char *spear600_dt_board_compat[] = {
> > +   "st,spear600-evb",
> > +   NULL
> > +};
> > +
> > +static const struct of_device_id vic_of_match[] __initconst = {
> > +   { .compatible = "arm,pl190-vic", .data = vic_of_init, },
> > +   { /* Sentinel */ }
> > +};
> > +
> > +static void __init spear6xx_dt_init_irq(vo

[PATCH v3] stmmac: Add device-tree support

2012-03-13 Thread Stefan Roese
This patch adds support to configure the STMMAC ethernet driver via
device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All
other properties should be added once needed on other platforms.

Signed-off-by: Stefan Roese 
Cc: Giuseppe Cavallaro 
---
v3:
- Fixed return value (removed ERR_PTR)
- Changed "gmac0: stmmac@e080" to "gmac0: ethernet@e080"
- Removed phy-addr for real from code
- Fixed indentation issue

v2:
- Renamed stm -> st
- Renamed compatible to "st,spear600-gmac"
- Removed "prog-burst-len", "had-gmac", has-pmt" properties.
  They are now implicitly set for "st,spear600-gmac" compatible
  devices.
- Removed phy-addr
- Used "if (pdev->dev.of_node)" to distinguish between DT
  and non-DT version instead of #ifdef

 Documentation/devicetree/bindings/net/stmmac.txt   |   28 
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   74 +++-
 2 files changed, 100 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt

diff --git a/Documentation/devicetree/bindings/net/stmmac.txt 
b/Documentation/devicetree/bindings/net/stmmac.txt
new file mode 100644
index 000..1f62623
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -0,0 +1,28 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "st,spear600-gmac"
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+
+Optional properties:
+- mac-address: 6 bytes, mac address
+
+Examples:
+
+   gmac0: ethernet@e080 {
+   compatible = "st,spear600-gmac";
+   reg = <0xe080 0x8000>;
+   interrupt-parent = <&vic1>;
+   interrupts = <24 23>;
+   interrupt-names = "macirq", "eth_wake_irq";
+   mac-address = []; /* Filled in by U-Boot */
+   phy-mode = "gmii";
+   };
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 3aad981..116529a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -24,8 +24,48 @@
 
 #include 
 #include 
+#include 
+#include 
 #include "stmmac.h"
 
+#ifdef CONFIG_OF
+static int __devinit stmmac_probe_config_dt(struct platform_device *pdev,
+   struct plat_stmmacenet_data *plat,
+   const char **mac)
+{
+   struct device_node *np = pdev->dev.of_node;
+
+   if (!np)
+   return -ENODEV;
+
+   *mac = of_get_mac_address(np);
+   plat->interface = of_get_phy_mode(np);
+   plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
+  sizeof(struct stmmac_mdio_bus_data),
+  GFP_KERNEL);
+
+   /*
+* Currently only the properties needed on SPEAr600
+* are provided. All other properties should be added
+* once needed on other platforms.
+*/
+   if (of_device_is_compatible(np, "st,spear600-gmac")) {
+   plat->pbl = 8;
+   plat->has_gmac = 1;
+   plat->pmt = 1;
+   }
+
+   return 0;
+}
+#else
+static int __devinit stmmac_probe_config_dt(struct platform_device *pdev,
+   struct plat_stmmacenet_data *plat,
+   const char **mac)
+{
+   return -ENOSYS;
+}
+#endif /* CONFIG_OF */
+
 /**
  * stmmac_pltfr_probe
  * @pdev: platform device pointer
@@ -39,7 +79,8 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *addr = NULL;
struct stmmac_priv *priv = NULL;
-   struct plat_stmmacenet_data *plat_dat;
+   struct plat_stmmacenet_data *plat_dat = NULL;
+   const char *mac = NULL;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
@@ -58,7 +99,25 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto out_release_region;
}
-   plat_dat = pdev->dev.platform_data;
+
+   if (pdev->dev.of_n

[PATCH] ARM: SPEAr600: Add device-tree support to SPEAr600 boards

2012-03-13 Thread Stefan Roese
This patch adds a generic target for SPEAr600 board that can be
configured via the device-tree. Currently only interrupts are
configured via device-tree. Other peripheral devices (e.g.
ethernet, I2C, SMI flash, FSMC NAND flash etc) will follow in
later patches.

Only the spear600-evb is currently supported. Other SPEAr600
based boards will follow later.

Signed-off-by: Stefan Roese 
Cc: Viresh Kumar 
---
 Documentation/devicetree/bindings/arm/spear.txt |6 ++
 arch/arm/boot/dts/spear600-evb.dts  |   23 +++
 arch/arm/boot/dts/spear600.dtsi |   49 +++
 arch/arm/mach-spear6xx/Kconfig  |7 +++
 arch/arm/mach-spear6xx/Makefile |1 +
 arch/arm/mach-spear6xx/board-dt.c   |   75 +++
 6 files changed, 161 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/spear.txt
 create mode 100644 arch/arm/boot/dts/spear600-evb.dts
 create mode 100644 arch/arm/boot/dts/spear600.dtsi
 create mode 100644 arch/arm/mach-spear6xx/board-dt.c

diff --git a/Documentation/devicetree/bindings/arm/spear.txt 
b/Documentation/devicetree/bindings/arm/spear.txt
new file mode 100644
index 000..8e9f83e
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/spear.txt
@@ -0,0 +1,6 @@
+ST SPEAr Platforms Device Tree Bindings
+---
+
+SPEAr600 EVB (Evaluation Board)
+Required root node properties:
+- compatible = "st,spear600-evb";
diff --git a/arch/arm/boot/dts/spear600-evb.dts 
b/arch/arm/boot/dts/spear600-evb.dts
new file mode 100644
index 000..f92d099
--- /dev/null
+++ b/arch/arm/boot/dts/spear600-evb.dts
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * Copyright 2012 Stefan Roese 
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+/include/ "spear600.dtsi"
+
+/ {
+   model = "ST SPEAr600 Evaluation Board";
+   compatible = "st,spear600-evb";
+   #address-cells = <1>;
+   #size-cells = <1>;
+};
diff --git a/arch/arm/boot/dts/spear600.dtsi b/arch/arm/boot/dts/spear600.dtsi
new file mode 100644
index 000..82b086d
--- /dev/null
+++ b/arch/arm/boot/dts/spear600.dtsi
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * Copyright 2012 Stefan Roese 
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/include/ "skeleton.dtsi"
+
+/ {
+   cpus {
+   cpu@0 {
+   compatible = "arm,arm926ejs";
+   };
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0 0>; /* Filled by U-Boot */
+   };
+
+   soc {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "simple-bus";
+   ranges;
+
+   vic0: interrupt-controller@f110 {
+   compatible = "arm,pl190-vic";
+   interrupt-controller;
+   reg = <0xf110 0x1000>;
+   #interrupt-cells = <1>;
+   };
+
+   vic1: interrupt-controller@f100 {
+   compatible = "arm,pl190-vic";
+   interrupt-controller;
+   reg = <0xf100 0x1000>;
+   #interrupt-cells = <1>;
+   };
+   };
+};
diff --git a/arch/arm/mach-spear6xx/Kconfig b/arch/arm/mach-spear6xx/Kconfig
index ff4ae5b..f72 100644
--- a/arch/arm/mach-spear6xx/Kconfig
+++ b/arch/arm/mach-spear6xx/Kconfig
@@ -11,6 +11,13 @@ config BOARD_SPEAR600_EVB
help
  Supports ST SPEAr600 Evaluation Board
 
+config BOARD_SPEAR600_DT
+   bool "SPEAr600 generic board configured via device-tree"
+   select MACH_SPEAR600
+   select USE_OF
+   help
+ Supports ST SPEAr600 boards configured via the device-tree
+
 endmenu
 
 config MACH_SPEAR600
diff --git a/arch/arm/mach-spear6xx/Makefile b/arch/arm/mach-spear6xx/Makefile
index cc1a4d8..e2d79b8 100644
--- a/arch/arm/mach-spear6xx/Makefile
+++ b/arch/arm/mach-spear6xx/Makefile
@@ -10,3 +10,4 @@ obj-$(CONFIG_MACH_SPEAR600) += spear600.o
 
 # spear600 boards files
 obj-$(CONFIG_BOARD_SPEAR600_EVB) += spear600_evb.o
+obj-$(CONFIG_BOARD_SPEAR600_D

Re: [PATCH v2] stmmac: Add device-tree support

2012-03-13 Thread Stefan Roese
Rob,

thanks for the review. I'll fix the issues and send an updated patch version.

Stefan

On Tuesday 13 March 2012 15:18:59 Rob Herring wrote:
> On 03/13/2012 02:23 AM, Stefan Roese wrote:
> > This patch adds support to configure the STMMAC ethernet driver via
> > device-tree instead of platform_data.
> > 
> > Currently, only the properties needed on SPEAr600 are provided. All
> > other properties should be added once needed on other platforms.
> > 
> > Signed-off-by: Stefan Roese 
> > Cc: Giuseppe Cavallaro 
> > ---
> > v2:
> > - Renamed stm -> st
> > - Renamed compatible to "st,spear600-gmac"
> > - Removed "prog-burst-len", "had-gmac", has-pmt" properties.
> > 
> >   They are now implicitly set for "st,spear600-gmac" compatible
> >   devices.
> > 
> > - Removed phy-addr
> > - Used "if (pdev->dev.of_node)" to distinguish between DT
> > 
> >   and non-DT version instead of #ifdef
> >  
> >  Documentation/devicetree/bindings/net/stmmac.txt   |   28 
> >  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   76
> >  +++- 2 files changed, 102 insertions(+), 2 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/net/stmmac.txt
> > b/Documentation/devicetree/bindings/net/stmmac.txt new file mode 100644
> > index 000..a91f4e1
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/stmmac.txt
> > @@ -0,0 +1,28 @@
> > +* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
> > +
> > +Required properties:
> > +- compatible: Should be "st,spear600-gmac"
> > +- reg: Address and length of the register set for the device
> > +- interrupt-parent: Should be the phandle for the interrupt controller
> > +  that services interrupts for this device
> > +- interrupts: Should contain the STMMAC interrupts
> > +- interrupt-names: Should contain the interrupt names "macirq"
> > +  "eth_wake_irq" if this interrupt is supported in the "interrupts"
> > +  property
> > +- phy-mode: String, operation mode of the PHY interface.
> > +  Supported values are: "mii", "rmii", "gmii", "rgmii".
> > +
> > +Optional properties:
> > +- mac-address: 6 bytes, mac address
> > +
> > +Examples:
> > +
> > +   gmac0: stmmac@e080 {
> 
> Use generic names: gmac0: ethernet@e080
> 
> > +   compatible = "st,spear600-gmac";
> > +   reg = <0xe080 0x8000>;
> > +   interrupt-parent = <&vic1>;
> > +   interrupts = <24 23>;
> > +   interrupt-names = "macirq", "eth_wake_irq";
> > +   mac-address = []; /* Filled in by U-Boot */
> > +   phy-mode = "gmii";
> > +   };
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index
> > 3aad981..ed8b477 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > @@ -24,8 +24,50 @@
> > 
> >  #include 
> >  #include 
> > 
> > +#include 
> > +#include 
> > 
> >  #include "stmmac.h"
> > 
> > +#ifdef CONFIG_OF
> > +static int __devinit stmmac_probe_config_dt(struct platform_device
> > *pdev, +struct 
plat_stmmacenet_data *plat,
> > +   const char **mac)
> > +{
> > +   struct device_node *np = pdev->dev.of_node;
> > +
> > +   if (!np)
> > +   return -ENODEV;
> > +
> > +   *mac = of_get_mac_address(np);
> > +
> > +   plat->interface = of_get_phy_mode(np);
> > +   of_property_read_u32(np, "phy-addr", &plat->phy_addr);
> 
> This property doesn't exist anymore.
> 
> > +   plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
> > +  sizeof(struct 
stmmac_mdio_bus_data),
> > +  GFP_KERNEL);
> > +
> > +   /*
> > +* Currently only the properties needed on SPEAr600
> > +* are provided. All other properties should be added
> > +* once needed on other platforms.
> > +*/
> > +if (of_device_is_compatible(np, "st,spear600-gmac")) {
> 

Re: [PATCH v2] stmmac: Add device-tree support

2012-03-13 Thread Stefan Roese
On Tuesday 13 March 2012 12:11:18 Viresh Kumar wrote:
> On 3/13/2012 3:59 PM, Stefan Roese wrote:
> > Consistency. pr_err is used in this driver. So I'm sticking to it with
> > this patch as well.
> 
> Hmmm. I don't know, but can you add another patch before this one to move
> those prints.

Sure, I could. But I have to admit that this is currently not top of my 
priority.

Peppe as driver maintainer might have some input here. Is this dev_err vs 
pr_err a show-stopper for this patch?

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH v2] stmmac: Add device-tree support

2012-03-13 Thread Stefan Roese
On Tuesday 13 March 2012 09:53:06 Viresh Kumar wrote:
> On 3/13/2012 12:53 PM, Stefan Roese wrote:
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> > 
> > +#ifdef CONFIG_OF
> > +static int __devinit stmmac_probe_config_dt(struct platform_device
> > *pdev, +struct 
plat_stmmacenet_data *plat,
> > +   const char **mac)
> > +{
> 
> 
> 
> > +}
> > +#else
> > +static int __devinit stmmac_probe_config_dt(struct platform_device
> > *pdev, +struct 
plat_stmmacenet_data *plat,
> > +   const char **mac)
> > +{
> > +   return ERR_PTR(-ENOSYS);
> 
> why ERR_PTR()?

Thanks for spotting. Will fix in next version.
 
> > +}
> > +#endif /* CONFIG_OF */
> > +
> > 
> >  /**
> >  
> >   * stmmac_pltfr_probe
> >   * @pdev: platform device pointer
> > 
> > @@ -58,7 +101,25 @@ static int stmmac_pltfr_probe(struct platform_device
> > *pdev)
> > 
> > ret = -ENOMEM;
> > goto out_release_region;
> > 
> > }
> > 
> > -   plat_dat = pdev->dev.platform_data;
> > +
> > +   if (pdev->dev.of_node) {
> > +   plat_dat = devm_kzalloc(&pdev->dev,
> > +   sizeof(struct 
plat_stmmacenet_data),
> > +   GFP_KERNEL);
> > +   if (!plat_dat) {
> > +   pr_err("%s: ERROR: no memory", __func__);
> 
> why don't we use dev_err here?

Consistency. pr_err is used in this driver. So I'm sticking to it with this 
patch as well.
 
Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH v2] stmmac: Add device-tree support

2012-03-13 Thread Stefan Roese
This patch adds support to configure the STMMAC ethernet driver via
device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All
other properties should be added once needed on other platforms.

Signed-off-by: Stefan Roese 
Cc: Giuseppe Cavallaro 
---
v2:
- Renamed stm -> st
- Renamed compatible to "st,spear600-gmac"
- Removed "prog-burst-len", "had-gmac", has-pmt" properties.
  They are now implicitly set for "st,spear600-gmac" compatible
  devices.
- Removed phy-addr
- Used "if (pdev->dev.of_node)" to distinguish between DT
  and non-DT version instead of #ifdef

 Documentation/devicetree/bindings/net/stmmac.txt   |   28 
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   76 +++-
 2 files changed, 102 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt

diff --git a/Documentation/devicetree/bindings/net/stmmac.txt 
b/Documentation/devicetree/bindings/net/stmmac.txt
new file mode 100644
index 000..a91f4e1
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -0,0 +1,28 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "st,spear600-gmac"
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+
+Optional properties:
+- mac-address: 6 bytes, mac address
+
+Examples:
+
+   gmac0: stmmac@e080 {
+   compatible = "st,spear600-gmac";
+   reg = <0xe080 0x8000>;
+   interrupt-parent = <&vic1>;
+   interrupts = <24 23>;
+   interrupt-names = "macirq", "eth_wake_irq";
+   mac-address = []; /* Filled in by U-Boot */
+   phy-mode = "gmii";
+   };
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 3aad981..ed8b477 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -24,8 +24,50 @@
 
 #include 
 #include 
+#include 
+#include 
 #include "stmmac.h"
 
+#ifdef CONFIG_OF
+static int __devinit stmmac_probe_config_dt(struct platform_device *pdev,
+   struct plat_stmmacenet_data *plat,
+   const char **mac)
+{
+   struct device_node *np = pdev->dev.of_node;
+
+   if (!np)
+   return -ENODEV;
+
+   *mac = of_get_mac_address(np);
+
+   plat->interface = of_get_phy_mode(np);
+   of_property_read_u32(np, "phy-addr", &plat->phy_addr);
+   plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
+  sizeof(struct stmmac_mdio_bus_data),
+  GFP_KERNEL);
+
+   /*
+* Currently only the properties needed on SPEAr600
+* are provided. All other properties should be added
+* once needed on other platforms.
+*/
+if (of_device_is_compatible(np, "st,spear600-gmac")) {
+   plat->pbl = 8;
+   plat->has_gmac = 1;
+   plat->pmt = 1;
+   }
+
+   return 0;
+}
+#else
+static int __devinit stmmac_probe_config_dt(struct platform_device *pdev,
+   struct plat_stmmacenet_data *plat,
+   const char **mac)
+{
+   return ERR_PTR(-ENOSYS);
+}
+#endif /* CONFIG_OF */
+
 /**
  * stmmac_pltfr_probe
  * @pdev: platform device pointer
@@ -39,7 +81,8 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *addr = NULL;
struct stmmac_priv *priv = NULL;
-   struct plat_stmmacenet_data *plat_dat;
+   struct plat_stmmacenet_data *plat_dat = NULL;
+   const char *mac = NULL;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
@@ -58,7 +101,25 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto out_release_region;
}
-   plat_dat = pdev->dev.platform_data;
+
+   if (pdev->dev.of_node) {
+   plat_dat = devm_kzalloc(&pdev->dev,
+   

Re: [PATCH] stmmac: Add device-tree support

2012-03-12 Thread Stefan Roese
On Monday 12 March 2012 16:30:37 Giuseppe CAVALLARO wrote:
> >>> +Required properties:
> >>> +- compatible: Should be "stm,gmac"
> >> 
> >> This is too generic. This should be 1 string per version of h/w.
> > 
> > Viresh, Giuseppe, can you please suggest a proper string for the SPEAr600
> > STMMAC core, including version?
> > 
> >> 'stm' should be 'st' according to vendor-prefixes.txt.
> 
> I'm not familiar with devicetree; maybe we should have:
> 
> "stmicro,mac100"
> "stmicro,gmac"
> 
> or: st instead of stmicro if you prefer.
> 
> in fact, stmmac is for mac100 and gmac devices.

How about "st,spear600-gmac" for SPEAr600 then?
 
> > Okay.
> > 
> >>> +- reg: Address and length of the register set for the device
> >>> +- interrupt-parent: Should be the phandle for the interrupt controller
> >>> +  that services interrupts for this device
> >>> +- interrupts: Should contain the STMMAC interrupts
> >>> +- interrupt-names: Should contain the interrupt names "macirq"
> >>> +  "eth_wake_irq" if this interrupt is supported in the "interrupts"
> >>> +  property
> >> 
> >> You should be able to tell this from the compatible string and number of
> >> interrupts.
> > 
> > Yes. Currently the driver uses platform_get_irq_byname() to register the
> > irq's. That's why I added these properties. Is there something wrong with
> > using it this way?
> > 
> >>> +- phy-mode: String, operation mode of the PHY interface.
> >>> +  Supported values are: "mii", "rmii", "gmii", "rgmii".
> >>> +- phy-addr: MDIO address of the PHY
> >> 
> >> This is normally probed or the mdio bus is a sub-node of the MAC node.
> >> See arch/powerpc/boot/dts/mpc8377_mds.dts for an example.
> > 
> > Okay, I'll rework this.
> > 
> >>> +
> >>> +Optional properties:
> >>> +- stm,prog-burst-len: Specify the burst length
> >>> +- stm,has-gmac: Indicates that the controller supports 1000Mbps
> >>> +- stm,has-pmt: Indicates that the controller supports power management
> >> 
> >> I think these should all be encoded by the compatible string.
> 
> and should we have all the other flags e.g. tx_coe etc?
> (see stmmac.txt)

As Rob suggested, some of these flags/parameters are implicitly defined by the 
compatible string. If this is not the case, then sure, those flags/parameters 
need to be provided via the device-tree as well. I just don't need "tx_coe" 
etc. for my platform (SPEAr600) as far as I know. I suggest to add support for 
them once they are really needed/used by other platforms.

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] stmmac: Add device-tree support

2012-03-12 Thread Stefan Roese
On Monday 12 March 2012 15:38:25 Jean-Christophe PLAGNIOL-VILLARD wrote:
> > @@ -58,6 +94,22 @@ static int stmmac_pltfr_probe(struct platform_device
> > *pdev)
> > 
> > ret = -ENOMEM;
> > goto out_release_region;
> > 
> > }
> > 
> > +
> > +#ifdef CONFIG_OF
> > +   plat_dat = devm_kzalloc(&pdev->dev, sizeof(struct
> > plat_stmmacenet_data), +GFP_KERNEL);
> > +   if (!plat_dat) {
> > +   pr_err("%s: ERROR: no memory", __func__);
> > +   ret = -ENOMEM;
> > +   goto out_unmap;
> > +   }
> > +
> > +   ret = stmmac_probe_config_dt(pdev, plat_dat, &mac);
> > +   if (ret) {
> > +   pr_err("%s: main dt probe failed", __func__);
> > +   goto out_unmap;
> > +   }
> > +#else
> 
> This must be check at runtime, we can boot a kernel with or without DT.

Are you referring to using "if (pdev->dev.of_node)" to distinguish between DT 
and non-DT version instead of this #ifdef?

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH] stmmac: Add device-tree support

2012-03-12 Thread Stefan Roese
Hi Rob,

On Monday 12 March 2012 15:34:59 Rob Herring wrote:
> On 03/12/2012 09:05 AM, Stefan Roese wrote:
> > This patch adds support to configure the STMMAC ethernet driver via
> > device-tree instead of platform_data.
> > 
> > Currently, only the properties needed on SPEAr600 are provided. All
> > other properties should be added once needed on other platforms.
> > 
> > Signed-off-by: Stefan Roese 
> > Cc: Giuseppe Cavallaro 
> > Cc: Viresh Kumar 
> > ---
> > 
> >  Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++
> >  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66
> >  +++- 2 files changed, 103 insertions(+), 1 deletion(-)
> >  create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/net/stmmac.txt
> > b/Documentation/devicetree/bindings/net/stmmac.txt new file mode 100644
> > index 000..386a47f
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/stmmac.txt
> > @@ -0,0 +1,38 @@
> > +* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
> > +
> > +Required properties:
> > +- compatible: Should be "stm,gmac"
> 
> This is too generic. This should be 1 string per version of h/w.

Viresh, Giuseppe, can you please suggest a proper string for the SPEAr600 
STMMAC core, including version?
 
> 'stm' should be 'st' according to vendor-prefixes.txt.

Okay.
 
> > +- reg: Address and length of the register set for the device
> > +- interrupt-parent: Should be the phandle for the interrupt controller
> > +  that services interrupts for this device
> > +- interrupts: Should contain the STMMAC interrupts
> > +- interrupt-names: Should contain the interrupt names "macirq"
> > +  "eth_wake_irq" if this interrupt is supported in the "interrupts"
> > +  property
> 
> You should be able to tell this from the compatible string and number of
> interrupts.

Yes. Currently the driver uses platform_get_irq_byname() to register the 
irq's. That's why I added these properties. Is there something wrong with 
using it this way?
 
> > +- phy-mode: String, operation mode of the PHY interface.
> > +  Supported values are: "mii", "rmii", "gmii", "rgmii".
> > +- phy-addr: MDIO address of the PHY
> 
> This is normally probed or the mdio bus is a sub-node of the MAC node.
> See arch/powerpc/boot/dts/mpc8377_mds.dts for an example.

Okay, I'll rework this.

> > +
> > +Optional properties:
> > +- stm,prog-burst-len: Specify the burst length
> > +- stm,has-gmac: Indicates that the controller supports 1000Mbps
> > +- stm,has-pmt: Indicates that the controller supports power management
> 
> I think these should all be encoded by the compatible string.

You mean that by defining a specific compatible string (e.g.
"st,gmac-spear600"), these settings are implicitly set? And should therefore 
be omitted from the dts?

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


[PATCH] stmmac: Add device-tree support

2012-03-12 Thread Stefan Roese
This patch adds support to configure the STMMAC ethernet driver via
device-tree instead of platform_data.

Currently, only the properties needed on SPEAr600 are provided. All
other properties should be added once needed on other platforms.

Signed-off-by: Stefan Roese 
Cc: Giuseppe Cavallaro 
Cc: Viresh Kumar 
---
 Documentation/devicetree/bindings/net/stmmac.txt   |   38 +++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   66 +++-
 2 files changed, 103 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/net/stmmac.txt

diff --git a/Documentation/devicetree/bindings/net/stmmac.txt 
b/Documentation/devicetree/bindings/net/stmmac.txt
new file mode 100644
index 000..386a47f
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -0,0 +1,38 @@
+* STMicroelectronics 10/100/1000 Ethernet driver (GMAC)
+
+Required properties:
+- compatible: Should be "stm,gmac"
+- reg: Address and length of the register set for the device
+- interrupt-parent: Should be the phandle for the interrupt controller
+  that services interrupts for this device
+- interrupts: Should contain the STMMAC interrupts
+- interrupt-names: Should contain the interrupt names "macirq"
+  "eth_wake_irq" if this interrupt is supported in the "interrupts"
+  property
+- phy-mode: String, operation mode of the PHY interface.
+  Supported values are: "mii", "rmii", "gmii", "rgmii".
+- phy-addr: MDIO address of the PHY
+
+Optional properties:
+- stm,prog-burst-len: Specify the burst length
+- stm,has-gmac: Indicates that the controller supports 1000Mbps
+- stm,has-pmt: Indicates that the controller supports power management
+- mac-address: 6 bytes, mac address
+
+Examples:
+
+   gmac0: stmmac@e080 {
+   compatible = "stm,gmac";
+   reg = <0xe080 0x8000>;
+   interrupt-parent = <&vic1>;
+   interrupts = <24 23>;
+   interrupt-names = "macirq", "eth_wake_irq";
+   mac-address = []; /* Filled in by U-Boot */
+
+   stm,prog-burst-len = <8>;
+   stm,has-gmac;
+   stm,has-pmt;
+
+   phy-mode = "gmii";
+   phy-addr = <0>;
+   };
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 
b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 3aad981..fcf46c7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -24,8 +24,43 @@
 
 #include 
 #include 
+#include 
+#include 
 #include "stmmac.h"
 
+#ifdef CONFIG_OF
+static int __devinit stmmac_probe_config_dt(struct platform_device *pdev,
+   struct plat_stmmacenet_data *plat,
+   const char **mac)
+{
+   struct device_node *np = pdev->dev.of_node;
+
+   if (!np)
+   return -ENODEV;
+
+   *mac = of_get_mac_address(np);
+
+   plat->interface = of_get_phy_mode(np);
+   of_property_read_u32(np, "phy-addr", &plat->phy_addr);
+   plat->mdio_bus_data = devm_kzalloc(&pdev->dev,
+  sizeof(struct stmmac_mdio_bus_data),
+  GFP_KERNEL);
+
+   /*
+* Currently only the properties needed on SPEAr600
+* are provided. All other properties should be added
+* once needed on other platforms.
+*/
+   of_property_read_u32(np, "stm,prog-burst-len", &plat->pbl);
+   if (of_get_property(np, "stm,has-gmac", NULL))
+   plat->has_gmac = 1;
+   if (of_get_property(np, "stm,has-pmt", NULL))
+   plat->pmt = 1;
+
+   return 0;
+}
+#endif /* CONFIG_OF */
+
 /**
  * stmmac_pltfr_probe
  * @pdev: platform device pointer
@@ -39,7 +74,8 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *addr = NULL;
struct stmmac_priv *priv = NULL;
-   struct plat_stmmacenet_data *plat_dat;
+   struct plat_stmmacenet_data *plat_dat = NULL;
+   const char *mac = NULL;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
@@ -58,6 +94,22 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
ret = -ENOMEM;
goto out_release_region;
}
+
+#ifdef CONFIG_OF
+   plat_dat = devm_kzalloc(&pdev->dev, sizeof(struct plat_stmmacenet_data),
+   GFP_KERNEL);
+   if (!plat_dat) {
+   pr_err("%s: ERROR: no memory", __func__);
+   ret = -ENOMEM;
+   goto out_unmap;
+   }
+
+   ret = stmmac_probe_config_

Re: [PATCH 4/6 v3] of/mtd/nand: add generic bindings and helpers

2012-02-07 Thread Stefan Roese
On Tuesday 07 February 2012 17:18:30 Jean-Christophe PLAGNIOL-VILLARD wrote:
> - nand-ecc-mode : String, operation mode of the NAND ecc mode.
>   Supported values are: "none", "soft", "hw", "hw_syndrome",
> "hw_oob_first", "soft_bch".
> - nand-bus-width : 8 or 16 bus width if not present 8
> - nand-on-flash-bbt: boolean to enable on flash bbt option if not present
> false
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD 
> Acked-by: Grant Likely 
> Cc: Rob Herring 
> Cc: devicetree-discuss@lists.ozlabs.org

Acked-by: Stefan Roese 

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 4/6 V2] of/mtd/nand: add generic bindings and helpers

2012-02-07 Thread Stefan Roese
On Tuesday 07 February 2012 05:16:06 Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > - nand-on-flash-bbt: boolean to enable on flash bbt option if not
> > > present false
> > 
> > Why not use an "empty" type (without argument) for nand-on-flash-bbt
> > then?
> 
> I want to be able to disable it

Then just don't add this property.
 
> I send a patch to add a helper to manage boolean
> 
> this will allow to disable a boolean
> 
> is-ok;  => true
> is-ok = <1>;=> true
> is-ok = <0>;=> false

Okay, fine with me.

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: [PATCH 4/6 V2] of/mtd/nand: add generic bindings and helpers

2012-02-06 Thread Stefan Roese
Hi Jean-Christophe,

On Monday 06 February 2012 11:35:11 Jean-Christophe PLAGNIOL-VILLARD wrote:
> - nand-ecc-mode : String, operation mode of the NAND ecc mode.
>   Supported values are: "none", "soft", "hw", "hw_syndrome",
> "hw_oob_first", "soft_bch".
> - nand-bus-width : 8 or 16 bus width if not present 8
> - nand-on-flash-bbt: boolean to enable on flash bbt option if not present
> false

Why not use an "empty" type (without argument) for nand-on-flash-bbt then?

Thanks,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: UIO / of_genirq driver

2010-12-03 Thread Stefan Roese
Wolfram,

On Thursday 28 January 2010 11:45:45 Wolfram Sang wrote:
> > I guess I'd like to just open up a discussion, see if there's been any
> > progress towards a general solution.
> 
> I decided to wait for the outcome of the of_platform-removal-idea. Though,
> I have to admit that in the last weeks I haven't followed of-related
> things due to other commitments.

Is there any update on this in the meantime? Do you know of any plans to re-
work/-push this patchset? Just checking...

Thanks,
Stefan

--
DENX Software Engineering GmbH,  MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: off...@denx.de
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: Question on of_address_to_resource() with offset != 0

2010-09-15 Thread Stefan Roese
On Tuesday 14 September 2010 16:29:06 Stefan Roese wrote:
> I'm stumbling upon a problem noticed on the Ebony (440GP) eval board.
> Here the first chip-select is connected to 512KiB of SRAM and 512KiB
> NOR flash.

"Brown paper bag" time for me. Problem was located in U-Boot. Sorry for the 
noise.

Cheers,
Stefan

--
DENX Software Engineering GmbH,  MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: off...@denx.de
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Question on of_address_to_resource() with offset != 0

2010-09-14 Thread Stefan Roese
Hi,

I'm stumbling upon a problem noticed on the Ebony (440GP) eval board.
Here the first chip-select is connected to 512KiB of SRAM and 512KiB
NOR flash. The dts part look this way:

small-fl...@0,8 {
compatible = "jedec-flash";
bank-width = <1>;
reg = <0x 0x0008 
0x0008>;
#address-cells = <1>;
#size-cells = <1>;
partit...@0 {
label = "OpenBIOS";
reg = <0x 0x0008>;
read-only;
};
};

Chip-select 0 has this setup:
base-addr = 0xfff0, size = 0x10 (phys addr 0x1fff0 .. 0x1)

The problem/crash happens in the physmap_of driver, when the the driver
calls do_map_probe() with the following range:
base-addr = 0xfff8, size = 0x10 (phys addr 0x1fff8 .. 0x20007)

My question now is, should of_address_to_resource() subtract the
offset (here 0x8) from the size? Is this is bug here? Or should
the physmap_of driver take care of this issue somehow?

Cheers,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


Re: dtc: Empty ranges property: #cells-size warning

2009-10-22 Thread Stefan Roese
On Thursday 22 October 2009 00:04:13 David Gibson wrote:
> > No, the warning is correct, and your device tree is in error.
> >
> > An empty "ranges" property means that the child address space is
> > identical to the parent address space, which isn't the case here.
> >
> > You should resolve this by using a non-empty "ranges" property,
> > instead.  If e.g. the address space is 1GB, and located at 0, you
> > would do
> >
> >< 00 00x4000 >
> > (child) (parent)(size)
> 
> Exactly.  An empty ranges property makes no sense if the parent and
> child address spaces aren't identical.  You need an explicit ranges
> property to show how the child address space is embedded in the
> parent's.

OK, thanks for making this clear.

Cheers,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss


dtc: Empty ranges property: #cells-size warning

2009-10-21 Thread Stefan Roese
Hi,

when changing #cells-size from 1 to 2 in the root node (to support >= 4GB of 
RAM in katmai.dts) I get the following warning:

Warning (ranges_format): /plb has empty "ranges" property but its #size-cells 
(1) differs from / (2)

I could change #cells-size to 2 in the plb node as well. But this not really 
what I want, because of it's child nodes.

So my questions is: How can I solve this problem? Perhaps this warning should 
be removed from dtc?

Thanks.

Cheers,
Stefan
___
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss