* [PATCH 1/2] eeprom: at25: Add dt probe support
@ 2014-05-15 6:39 Sascha Hauer
2014-05-15 6:39 ` [PATCH 2/2] mtd: m25p80: update Micron IDs Sascha Hauer
0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2014-05-15 6:39 UTC (permalink / raw)
To: barebox
The parsing code has been taken directly from Linux 3.15-rc5.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/eeprom/at25.c | 98 ++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 86 insertions(+), 12 deletions(-)
diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c
index 0a099e1..266f261 100644
--- a/drivers/eeprom/at25.c
+++ b/drivers/eeprom/at25.c
@@ -238,27 +238,94 @@ static struct file_operations at25_fops = {
.lseek = dev_lseek_default,
};
+static int at25_np_to_chip(struct device_d *dev,
+ struct device_node *np,
+ struct spi_eeprom *chip)
+{
+ u32 val;
+
+ if (!IS_ENABLED(CONFIG_OFDEVICE))
+ return -ENODEV;
+
+ memset(chip, 0, sizeof(*chip));
+ strncpy(chip->name, np->name, sizeof(chip->name));
+
+ if (of_property_read_u32(np, "size", &val) == 0 ||
+ of_property_read_u32(np, "at25,byte-len", &val) == 0) {
+ chip->size = val;
+ } else {
+ dev_err(dev, "Error: missing \"size\" property\n");
+ return -ENODEV;
+ }
+
+ if (of_property_read_u32(np, "pagesize", &val) == 0 ||
+ of_property_read_u32(np, "at25,page-size", &val) == 0) {
+ chip->page_size = (u16)val;
+ } else {
+ dev_err(dev, "Error: missing \"pagesize\" property\n");
+ return -ENODEV;
+ }
+
+ if (of_property_read_u32(np, "at25,addr-mode", &val) == 0) {
+ chip->flags = (u16)val;
+ } else {
+ if (of_property_read_u32(np, "address-width", &val)) {
+ dev_err(dev,
+ "Error: missing \"address-width\" property\n");
+ return -ENODEV;
+ }
+ switch (val) {
+ case 8:
+ chip->flags |= EE_ADDR1;
+ break;
+ case 16:
+ chip->flags |= EE_ADDR2;
+ break;
+ case 24:
+ chip->flags |= EE_ADDR3;
+ break;
+ default:
+ dev_err(dev,
+ "Error: bad \"address-width\" property: %u\n",
+ val);
+ return -ENODEV;
+ }
+ if (of_find_property(np, "read-only", NULL))
+ chip->flags |= EE_READONLY;
+ }
+ return 0;
+}
+
static int at25_probe(struct device_d *dev)
{
int err, sr;
int addrlen;
struct at25_data *at25 = NULL;
- const struct spi_eeprom *chip;
+ struct spi_eeprom *chip;
+
+ at25 = xzalloc(sizeof(*at25));
/* Chip description */
- chip = dev->platform_data;
- if (!chip) {
- dev_dbg(dev, "no chip description\n");
- err = -ENODEV;
- goto fail;
+ if (dev->device_node) {
+ err = at25_np_to_chip(dev, dev->device_node, &at25->chip);
+ if (err)
+ goto fail;
+ } else {
+ chip = dev->platform_data;
+ if (!chip) {
+ dev_dbg(dev, "no chip description\n");
+ err = -ENODEV;
+ goto fail;
+ }
+ at25->chip = *chip;
}
/* For now we only support 8/16/24 bit addressing */
- if (chip->flags & EE_ADDR1) {
+ if (at25->chip.flags & EE_ADDR1) {
addrlen = 1;
- } else if (chip->flags & EE_ADDR2) {
+ } else if (at25->chip.flags & EE_ADDR2) {
addrlen = 2;
- } else if (chip->flags & EE_ADDR3) {
+ } else if (at25->chip.flags & EE_ADDR3) {
addrlen = 3;
} else {
dev_dbg(dev, "unsupported address type\n");
@@ -266,14 +333,12 @@ static int at25_probe(struct device_d *dev)
goto fail;
}
- at25 = xzalloc(sizeof(*at25));
- at25->chip = *chip;
at25->addrlen = addrlen;
at25->spi = dev->type_data;
at25->spi->mode = SPI_MODE_0;
at25->spi->bits_per_word = 8;
at25->cdev.ops = &at25_fops;
- at25->cdev.size = chip->size;
+ at25->cdev.size = at25->chip.size;
at25->cdev.dev = dev;
at25->cdev.name = at25->chip.name[0] ? at25->chip.name : DRIVERNAME;
at25->cdev.priv = at25;
@@ -299,8 +364,17 @@ fail:
return err;
}
+static __maybe_unused struct of_device_id at25_dt_ids[] = {
+ {
+ .compatible = "atmel,at25",
+ }, {
+ /* sentinel */
+ }
+};
+
static struct driver_d at25_driver = {
.name = DRIVERNAME,
+ .of_compatible = DRV_OF_COMPAT(at25_dt_ids),
.probe = at25_probe,
};
device_spi_driver(at25_driver);
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] mtd: m25p80: update Micron IDs
2014-05-15 6:39 [PATCH 1/2] eeprom: at25: Add dt probe support Sascha Hauer
@ 2014-05-15 6:39 ` Sascha Hauer
2014-05-15 8:19 ` Holger Schurig
0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2014-05-15 6:39 UTC (permalink / raw)
To: barebox
Update Micron IDs from Linux-3.15-rc5
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/devices/m25p80.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 50e0454..bc07307 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -659,8 +659,11 @@ static const struct platform_device_id m25p_ids[] = {
{ "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
/* Micron */
- { "n25q128", INFO(0x20ba18, 0, 64 * 1024, 256, 0) },
- { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) },
+ { "n25q064", INFO(0x20ba17, 0, 64 * 1024, 128, 0) },
+ { "n25q128a11", INFO(0x20bb18, 0, 64 * 1024, 256, 0) },
+ { "n25q128a13", INFO(0x20ba18, 0, 64 * 1024, 256, 0) },
+ { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K) },
+ { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },
/* Spansion -- single (large) sector size only, at least
* for the chips listed here (without boot sectors).
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mtd: m25p80: update Micron IDs
2014-05-15 6:39 ` [PATCH 2/2] mtd: m25p80: update Micron IDs Sascha Hauer
@ 2014-05-15 8:19 ` Holger Schurig
2014-05-15 10:53 ` Sascha Hauer
0 siblings, 1 reply; 4+ messages in thread
From: Holger Schurig @ 2014-05-15 8:19 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
> + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },
Are you sure that this one works? In u-boot's
drivers/mtd/spi/sf_params.c this one is marked with WR_QPP | E_FSR |
SECT_4K, and barebox doesn't support E_FSR right now. I have a WIP
patch for it, but haven't published that patch because even with it my
JEDEC 20ba20 N25Q512 doesn't get erased.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mtd: m25p80: update Micron IDs
2014-05-15 8:19 ` Holger Schurig
@ 2014-05-15 10:53 ` Sascha Hauer
0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-15 10:53 UTC (permalink / raw)
To: Holger Schurig; +Cc: barebox
On Thu, May 15, 2014 at 10:19:27AM +0200, Holger Schurig wrote:
> > + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K) },
>
> Are you sure that this one works? In u-boot's
> drivers/mtd/spi/sf_params.c this one is marked with WR_QPP | E_FSR |
> SECT_4K, and barebox doesn't support E_FSR right now. I have a WIP
> patch for it, but haven't published that patch because even with it my
> JEDEC 20ba20 N25Q512 doesn't get erased.
No, I'm not sure. I only need (and tested) the n25q128a13. I thought
I just update all, but maybe it's better to only add the one I tested.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-15 10:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-15 6:39 [PATCH 1/2] eeprom: at25: Add dt probe support Sascha Hauer
2014-05-15 6:39 ` [PATCH 2/2] mtd: m25p80: update Micron IDs Sascha Hauer
2014-05-15 8:19 ` Holger Schurig
2014-05-15 10:53 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox