Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1642987 > unrolled thread
| Started by | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| First post | 2017-05-17 07:40 +0200 |
| Last post | 2017-05-18 06:40 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024 Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-05-17 07:40 +0200
Re: [PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024 Andrew Lunn <andrew@lunn.ch> - 2017-05-17 14:20 +0200
Re: [PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024 Chris Packham <Chris.Packham@alliedtelesis.co.nz> - 2017-05-18 06:40 +0200
| From | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| Date | 2017-05-17 07:40 +0200 |
| Subject | [PATCH 4/4] mtd: mchp23k256: Add support for mchp23lcv1024 |
| Message-ID | <tHZQK-7s4-17@gated-at.bofh.it> |
The mchp23lcv1024 is software compatible with the mchp23k256, the
only difference (from a software point of view) is the size. There
is no way to detect the size so we must be told via a Device Tree.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
.../bindings/mtd/microchip,mchp23k256.txt | 2 +-
drivers/mtd/devices/mchp23k256.c | 21 +++++++++++++++++++--
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
index 25e5ad38b0f0..7328eb92a03c 100644
--- a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
+++ b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
@@ -3,7 +3,7 @@
Required properties:
- #address-cells, #size-cells : Must be present if the device has sub-nodes
representing partitions.
-- compatible : Must be "microchip,mchp23k256"
+- compatible : Must be one of "microchip,mchp23k256" or "microchip,mchp23lcv1024"
- reg : Chip-Select number
- spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at
diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
index 02c6b9dcbd3e..d1eba587633c 100644
--- a/drivers/mtd/devices/mchp23k256.c
+++ b/drivers/mtd/devices/mchp23k256.c
@@ -21,6 +21,8 @@
#include <linux/spi/spi.h>
#include <linux/of_device.h>
+enum chips { mchp23k256, mchp23lcv1024 };
+
struct mchp23k256_flash {
struct spi_device *spi;
struct mutex lock;
@@ -128,6 +130,7 @@ static int mchp23k256_probe(struct spi_device *spi)
struct mchp23k256_flash *flash;
struct flash_platform_data *data;
int err;
+ enum chips chip;
flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL);
if (!flash)
@@ -143,15 +146,28 @@ static int mchp23k256_probe(struct spi_device *spi)
data = dev_get_platdata(&spi->dev);
+ if (spi->dev.of_node)
+ chip = (enum chips)of_device_get_match_data(&spi->dev);
+ else
+ chip = mchp23k256;
+
mtd_set_of_node(&flash->mtd, spi->dev.of_node);
flash->mtd.dev.parent = &spi->dev;
flash->mtd.type = MTD_RAM;
flash->mtd.flags = MTD_CAP_RAM;
flash->mtd.writesize = 1;
- flash->mtd.size = SZ_32K;
flash->mtd._read = mchp23k256_read;
flash->mtd._write = mchp23k256_write;
+ switch (chip){
+ case mchp23lcv1024:
+ flash->mtd.size = SZ_128K;
+ break;
+ default:
+ flash->mtd.size = SZ_32K;
+ break;
+ }
+
flash->mtd.erasesize = PAGE_SIZE;
while (flash->mtd.size & (flash->mtd.erasesize - 1))
flash->mtd.erasesize >>= 1;
@@ -172,7 +188,8 @@ static int mchp23k256_remove(struct spi_device *spi)
}
static const struct of_device_id mchp23k256_of_table[] = {
- { .compatible = "microchip,mchp23k256" },
+ { .compatible = "microchip,mchp23k256", .data = (void *)mchp23k256 },
+ { .compatible = "microchip,mchp23lcv1024", .data = (void *)mchp23lcv1024 },
{}
};
MODULE_DEVICE_TABLE(of, mchp23k256_of_table);
--
2.11.0.24.ge6920cf
[toc] | [next] | [standalone]
| From | Andrew Lunn <andrew@lunn.ch> |
|---|---|
| Date | 2017-05-17 14:20 +0200 |
| Message-ID | <tI65Q-2Z7-9@gated-at.bofh.it> |
| In reply to | #1642987 |
> + switch (chip){
Space please, between ) and {
Andrew
[toc] | [prev] | [next] | [standalone]
| From | Chris Packham <Chris.Packham@alliedtelesis.co.nz> |
|---|---|
| Date | 2017-05-18 06:40 +0200 |
| Message-ID | <tIlod-4Qv-1@gated-at.bofh.it> |
| In reply to | #1642987 |
On 17/05/17 17:39, Chris Packham wrote:
> The mchp23lcv1024 is software compatible with the mchp23k256, the
> only difference (from a software point of view) is the size. There
> is no way to detect the size so we must be told via a Device Tree.
I've just noticed that another difference between the 2 chips is 16-bit
vs 24-bit addressing. So that will also need to be handled.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> .../bindings/mtd/microchip,mchp23k256.txt | 2 +-
> drivers/mtd/devices/mchp23k256.c | 21 +++++++++++++++++++--
> 2 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
> index 25e5ad38b0f0..7328eb92a03c 100644
> --- a/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
> +++ b/Documentation/devicetree/bindings/mtd/microchip,mchp23k256.txt
> @@ -3,7 +3,7 @@
> Required properties:
> - #address-cells, #size-cells : Must be present if the device has sub-nodes
> representing partitions.
> -- compatible : Must be "microchip,mchp23k256"
> +- compatible : Must be one of "microchip,mchp23k256" or "microchip,mchp23lcv1024"
> - reg : Chip-Select number
> - spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at
>
> diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
> index 02c6b9dcbd3e..d1eba587633c 100644
> --- a/drivers/mtd/devices/mchp23k256.c
> +++ b/drivers/mtd/devices/mchp23k256.c
> @@ -21,6 +21,8 @@
> #include <linux/spi/spi.h>
> #include <linux/of_device.h>
>
> +enum chips { mchp23k256, mchp23lcv1024 };
> +
> struct mchp23k256_flash {
> struct spi_device *spi;
> struct mutex lock;
> @@ -128,6 +130,7 @@ static int mchp23k256_probe(struct spi_device *spi)
> struct mchp23k256_flash *flash;
> struct flash_platform_data *data;
> int err;
> + enum chips chip;
>
> flash = devm_kzalloc(&spi->dev, sizeof(*flash), GFP_KERNEL);
> if (!flash)
> @@ -143,15 +146,28 @@ static int mchp23k256_probe(struct spi_device *spi)
>
> data = dev_get_platdata(&spi->dev);
>
> + if (spi->dev.of_node)
> + chip = (enum chips)of_device_get_match_data(&spi->dev);
> + else
> + chip = mchp23k256;
> +
> mtd_set_of_node(&flash->mtd, spi->dev.of_node);
> flash->mtd.dev.parent = &spi->dev;
> flash->mtd.type = MTD_RAM;
> flash->mtd.flags = MTD_CAP_RAM;
> flash->mtd.writesize = 1;
> - flash->mtd.size = SZ_32K;
> flash->mtd._read = mchp23k256_read;
> flash->mtd._write = mchp23k256_write;
>
> + switch (chip){
> + case mchp23lcv1024:
> + flash->mtd.size = SZ_128K;
> + break;
> + default:
> + flash->mtd.size = SZ_32K;
> + break;
> + }
> +
> flash->mtd.erasesize = PAGE_SIZE;
> while (flash->mtd.size & (flash->mtd.erasesize - 1))
> flash->mtd.erasesize >>= 1;
> @@ -172,7 +188,8 @@ static int mchp23k256_remove(struct spi_device *spi)
> }
>
> static const struct of_device_id mchp23k256_of_table[] = {
> - { .compatible = "microchip,mchp23k256" },
> + { .compatible = "microchip,mchp23k256", .data = (void *)mchp23k256 },
> + { .compatible = "microchip,mchp23lcv1024", .data = (void *)mchp23lcv1024 },
> {}
> };
> MODULE_DEVICE_TABLE(of, mchp23k256_of_table);
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web